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

Keith Corona
Keith Corona
9,553 Points

Sticky footer: unsure how flex-grow pushes the footer to the base - why?

In the video I watched, Guil shows us how to make a sticky footer with flexbox. Everything makes sense and was explained simply, but I am not completely understanding why using flex-grow would be successful in pushing the footer to the base of the viewport. This is the snippet of code that I am questioning. I understand that it is good syntax, but just not sure why it eliminates the gap forcing footer to the base.

.row {
     flex: 1;
}

1 Answer

flex-gow stretches the height of .row to the maximum of available space. Guil explains it on minute 2:30.

without flex-grow, the height of .row is defined by its content. with flex-grow, its takes all the available space thats left inside the viewport.

this is my favorite guide for flexbox when i need to recheck something: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

hope it helps you!