Created
October 23, 2009 23:19
-
-
Save rajeshg/217261 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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