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 Layout Basics Getting Started with CSS Layout Creating a Sticky Footer

Christopher Mlalazi
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Christopher Mlalazi
Front End Web Development Techdegree Graduate 17,305 Points

Sticky Footer Screen Size

Why set the sticky footer inside a media query and especially at width 769px? Doesn't this mean that at widths smaller than this it wont work and we will be back to the same scrolling problem?

5 Answers

Hi Christopher,

The scrolling issue was only caused by setting the min-height of the wrap div to 100vh. But this was set inside the media query. So when the media doesn't apply (when the viewport is wider than 769px), the style won't take place. So no scrolling issue.

(The code below just for reference)

@media (min-height: 769px) {
  .wrap {
     min-height: calc(100vh - 89px);
  }
}

Hope that helps,

Ede

Hi Christopher,

I assume that Guil has done that because if a screen's width is less than 769px, it's more than likely that it's height won't exceed the height of the content. Therefore there won't be an issue with the footer rising up.

It's not necessary though; you could place it outside of the media query and it would work just the same.

All the best,

Ede

Jeremiah Shore
Jeremiah Shore
31,168 Points

Christopher Mlalazi, I think Ede's point was that you don't exactly NEED to put it outside the media query. On devices with smaller screens, the chances are much less likely of the page content being short enough to cause space between the bottom of the footer and the bottom of the viewport to appear. However, as long as there is a chance that one of the pages will be short enough to not fill the viewport, AND the code is not in the right place, then the footer will unstick. This applies to this specific example web page when narrower than 769px, but this also depends on the browser height.

Placing the sticky footer CSS in the base layout styles would fix this, and honestly, I think it's the best option because it's a more uniform design.

Jeremiah Shore
Jeremiah Shore
31,168 Points

No worries, that was mostly for me anyway lol. Working to clearly explain something technical is a great way to retain understanding!