Sticky Footer – Make Footer Stick to the Bottom with Javascript

This is an update to this post. The method described below is quite old and since then browser support has gotten much better for different features provided by CSS. So I believe there is no need to use javascript anymore. You should be able to achieve this with a full CSS solution. Check out this post:
I personally like the Flexbox method and I have used it on this very site. In case you are still supporting really old browser versions, in that case the javascript method below might save you some headaches.

Old Post:

Recently I redesigned my company website. There was an issue I came across when I implemented the design on pages that were a little shallow on content. My footer tended to show a little higher where the content ended, leaving some space under it. Ofcourse, this did not look good to me.

So I started out trying different things, my first take was that I can do this with only CSS. I tried a different things but it worked in one browser and didn’t work in the other. So finally I decided to use Javascript. I found a solution that worked in all major browsers.

Below is the code:

  var viewportHeight = $(window).height();
  if(viewportHeight > 792){

$(window).resize(function() {
var newHeight = $(window).height();
if(newHeight > 792){
  } else {

function adjustFooter (){


Leave a Reply

Your email address will not be published. Required fields are marked *