Responsive jQuery Sticky Footer

Being able to add a sticky footer seems to be a reoccurring issue for many sites, yet solutions have been freely available online for several years.


I found the best solution to be CSS Sticky Footer by Ryan Fait, while an awesome piece of work, it did not take into account responsive code and required a fixed height for all elements in order to work.


I took Ryan’s solution and added some jQuery to work both on responsive and page load, no matter what the footer height. This made my solution usable on any website, when configured with the correct HTML structure, and without the need to work out footer heights on load or at certain breakpoints.



Here’s how the sticky footer works



Use the following structure, wrapping the main website content and leaving the sticky footer outside.


   <div id="wrapper">

         // Header code



        // Website content


      <div id="push"></div>



    // Footer code





Use this CSS to ensure the right containers are set to full height.

body, html {
   height: 100%;

#wrapper {
   min-height: 100%;
   height: auto !important;
   height: 100%;



This is the part which allows for my responsive website to always keep the sticky footer stuck to the bottom.

$(document).bind("ready", function() {
function sticky() {
   var fh = $("footer").outerHeight();
   $("#push").css({'height': fh});
   $("#wrapper").css({'margin-bottom': -fh});