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 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,373 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 6,191 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.