Skip to content

Instantly share code, notes, and snippets.

@rajeshg
Created October 23, 2009 23:19
Show Gist options
  • Save rajeshg/217261 to your computer and use it in GitHub Desktop.
Save rajeshg/217261 to your computer and use it in GitHub Desktop.
/**
* @author rajesh gollapudi
*/
$(document).ready(function(){
placeFooter();
$(function(){
$(window).resize(function(){
// console.log('You resized the window!');
if ($('#footer-spacer').length) {
$('#footer-spacer').remove();
}
placeFooter();
});
});
});
function placeFooter(){
// console.log("window height: " + $(window).height());
var bottom = $('#footer').position().top + $('#footer').height();
// console.log("footer position: " + bottom);
if (bottom < $(window).height()) {
var diff = $(window).height() - bottom;
// We need to add bottom padding to this difference. This is to push the footer up a little bit, if the footer has any padding defined.
var padding = parseInt($('#footer').css('padding-bottom')) + parseInt($('#footer').css('padding-top'));
diff = diff - padding;
$('#footer').before("<div id='footer-spacer' style='height:" + diff + "px;'></div>");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment