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 CSS Layout Techniques Flexbox Layout Animating Flexbox

David Service
David Service
12,928 Points

Transition Animation with Flex-Grow

At the end of the lesson, Guil gives the following initial-state declaration to get our flex item button to grow on a hover state:

.main-nav li {margin-left: 8px; margin-right: 8px; -webkit-align-self: center; align-self: center; -webkit-flex-grow: 1; flex-grow: 1; transition: .5s; }

My question is, why doesn't Guil give a transition property value of "transition: flex-grow .5s" instead (as we were taught to do in previous lessons)? Is it unnecessary with the use of Flexbox?

1 Answer


There are two ways to provide transitions, one is specifically on a property for a selector, and the other is a general set time transition for all properties with the selector.

You generally do the second option when you want to transition more than one property under the selector.

Both ways are correct, the second was just easier to implement because you don't have to specify any properties and your still given the same outcome.

David Service
David Service
12,928 Points

Hi Shawn,

Thanks for clearing that up for me (it was driving me nuts).

So if I understand you correctly, we can simply give a transition time value that will apply to any differing values between the initial element state and the target state, and they will all change according to the general transition time value?


Yes sir that is correct. I'm glad that helps. Take care.