Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Lili Köves
Lili Köves
3,471 Points

Flex container problem - hover effect increases letter-spacing, but that changes width of flex containers. Why?

I am practicing what I learnt about flexbox and transitions. So I have two flex items side by side (<div class="secondary promo"> and <div class="terciary promo"> ), have some text inside both. Applied a transition that on hovering increases the letterspacing of these texts. Weirdly that also increases the width of their parent containers and I can not find out why. What does cause this and how can I solve this so that the parent containers do not change?

Here is a snapshot of my workspace: https://w.trhou.se/brz3htdhlp

Thank you for any tips or comments!

2 Answers

Steven Parker
Steven Parker
230,024 Points

The default for flex-basis is "auto".

But if you change it to something else, the containers should not expand:

  .supporting > div {
    flex-basis: 0;
  }

You could also use the shorthand: "flex: 1;"

Lili Köves
Lili Köves
3,471 Points

It perfectly worked! Thank you! May I ask what the > means in .supporting > div ? I noticed if that is missing the containers still do expand.

Steven Parker
Steven Parker
230,024 Points

The ">" symbol is the child combinator. The entire selector targets "DIV elements that are direct children of the element with class supporting".