Sticky Page Footers

Occasionally you’ll be coding out a site, and you want a “sticky footer”, a footer that sticks to the bottom of the browser viewport or the bottom of the main content section, whichever is lowest.

There are a few notable sites that have posted methods for doing this, but the short answer is it doesn’t work unless you meet certain requirements. Probably the most popular example (which is also the first google result for “sticky footer”) is A CSS Sticky Footer. However, as the explanation page shows, the method uses extraneous markup to push the footer down below the content. Also, this method only works with static-height footers.

Another good example comes from AListApart: Exploring Footers. The method involves using relative positioning on a container and absolutely positioning the footer to the bottom of that container. Inexplicably, this works, though for my implementation, I used the body element as my wrapper. Unfortunately, you have to apply appropriate padding or margin to the bottom of the content div, which in turn squashes the idea of having a dynamic-height footer.

Given these examples, which are perfect for fixed-height footers, it seems sticky, dynamic-height footers are not meant to be under current browser implementations. If you’re insistent on having a dynamic-height sticky, you’ll have to go the way of the faux footer (along the lines of the faux columns, which I’ve always thought to be cheating :) ). I couldn’t find any links talking about faux columns (in this sense, anyway), but one site which currently implements it is KilianValkhof.com. If you look into his code, you’ll see that the background of the footer is actually set in the body.

3 Comments:

  1. Very nice!!

  2. Hey,

    Could you be able to find a way to implement sticky footer with dynamic height?

  3. Reza, you could conceivably do a dynamic-height footer, but it would overlap content, unless you knew the max-height of the footer, then you could use that max as the “buffer zone” at the bottom of the page. But really, it’s currently impossible to do a truly dynamic footer AND have it sticky.

    Can’t have your cake and eat it, too :)

No Pingbacks

Leave a Comment

You need to enable javascript in order to use Simple CAPTCHA.
Security Code: