Skip to content

Instantly share code, notes, and snippets.

@ardysnippets
Created March 13, 2012 07:22
Show Gist options
  • Save ardysnippets/2027408 to your computer and use it in GitHub Desktop.
Save ardysnippets/2027408 to your computer and use it in GitHub Desktop.
JavaScript: Auto-adjust footer position
/**
* Global JS file
*/
$(function() {
// adjust the footer position
setInterval(function(){
var footer = '.footer';
var resize = $('.container').height() + $(footer).height() > $(window).height();
$(footer).css({"position": resize ? "static" : "fixed"});
$('body').css({"height":($(document).height() - $(footer).height()) + "px"});
}, 1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment