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 Flexbox Layout Building a Layout with Flexbox Creating a Sticky Footer with Flexbox

Is using flex-grow better than using margin-top: auto for this exercise?

When I play around with the code it works also by applying margin-top: auto; to the main-footer. I'm just wondering if there are any downsides to using margin-top: auto; ?

Is there a preferred way, or are there numerous ways to create a sticky footer?

1 Answer

Christopher Debove
PLUS
Christopher Debove
Courses Plus Student 18,371 Points

There's different ways to create a sticky footer. In this example is by making the main content grow vertically to make the footer stick to the bottom.

But like you did it, by setting a margin-top: auto to your footer is more semantic, because you're really sticking your footer to the bottom.

Try adding a background to the .row element to see the differences between the 2 solutions.

Donovan Jackson
Donovan Jackson
Courses Plus Student 4,534 Points

Wow. I was wondering the same thing, because when margin-top blew my mind, I was thinking I was going to use it everywhere I could.

Your suggestion to check the difference between the two solutions through using a background was genius and eye opening. Thank you.