Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
A sticky footer is a footer that sticks to the bottom of the page, regardless of the amount of content on the page. If a page’s content is shorter than the height of the browser, you end up with a footer that sits near the middle of the page, instead of at the bottom. Flexbox is a great solution for fixing these types of problems.
Resources
- min-height - MDN
- Flexbox Froggy - A fun way to practice flexbox
Video review
- When you make
body
a flex container, it lays out all its direct children horizontally on a single line. - Setting the
flex-direction
ofbody
tocolumn
stacks its flex items vertically. -
1vh
is equal to 1/100th or 1% of the viewport height.
Sticky footer snippet
body {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.row {
flex: 1;
}
Alternate sticky footer method
body {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.main-footer {
margin-top: auto;
}
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up