Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.