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 trialJohn Boudreaux
Front End Web Development Techdegree Student 3,238 PointsSticky Footer Not Sticking
See my code below. I cant figure out why the sticky footer is not sticking. I tried adding margin: 0; to the body and I have also tried taking the .wrap out of the media query. No luck yet. Any suggestions?
Thanks!!!
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Best City Guide</title> <link rel="stylesheet" href="css/normalize.css"> <link rel="stylesheet" href="css/style.css"> </head> <body> <div class="wrap"> <header class="main-header"> <div class="container"> <h1 class="name"><a href="#">Best City Guide</a></h1> <ul class="main-nav"> <li><a href="#">ice cream</a></li> <li><a href="#">donuts</a></li> <li><a href="#">tea</a></li> <li><a href="#">coffee</a></li> </ul> </div> </header> <div class="container"> <h2>Welcome!</h2> <p>Everything in this city is worth waiting in line for.</p> <p>...</p>
<h2>Great food</h2>
<p>...</p>
</div> </div>
<footer class="main-footer">
<span>©2015 Residents of The Best City Ever.</span>
</footer>
</body> </html>
/* ================================= Base Element Styles ==================================== */
- { box-sizing: border-box; }
body { line-height: 1.6; color: #3a3a3a;
}
h1 { margin-top: 0; }
a { color: #fff; text-decoration: none; }
/* ================================= Base Layout Styles ==================================== */
/* ---- Navigation ---- */
.name { margin: 0; }
/* ---- Layout Containers ---- */
.container { padding-left: 1em; padding-right: 1em; }
.main-header { background: #3acec2; padding: 1em 0; }
.main-footer { text-align:center; padding: 2em 0; background: #d9e4ea; }
/* ---- Page Elements ---- */
/* ================================= Media Queries ==================================== */
@media (min-width: 769px) {
.wrap { min-height: calc(100vh - 89px); }
.container { width: 70%; max-width: 1000px; margin: 0 auto;
} }
2 Answers
Steven Parker
231,269 PointsIt seems like it's working fine to me, but I had to zoom out on my browser view to see it.
Here's another technique, not what's introduced in the course, but it will stick it like super glue regardless of the other element sizes:
.main-footer {
/* other settings... */
position: fixed;
width: 100%;
bottom: 0;
}
David Love
1,840 PointsThanks Steven Parker, works like a dream!
Naty Sipka
5,212 PointsThank you, that finally worked for me! :)
renhe
10,282 PointsWith this solution, is the wrapper still necessary?
venkateshwarluyagatilee
8,793 Pointsmake sure you give some space before and after "-" sign ........(100vh - 89px);
Thomas Doyle-Engler
6,005 PointsThomas Doyle-Engler
6,005 PointsIs your browser expanded past 769px? I had my browser on half my screen and workspace on the other half and it didn't work and after about 5 minutes of trying to figure out if i typed something wrong.... i realized it was just my browser wasn't large enough for it to take affect.