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
Christopher Debove
Pro Student 18,366 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.