Skip to content

Instantly share code, notes, and snippets.

@CrowderSoup
Created May 20, 2014 22:58
Show Gist options
  • Save CrowderSoup/203f6bf96937d7726bd4 to your computer and use it in GitHub Desktop.
Save CrowderSoup/203f6bf96937d7726bd4 to your computer and use it in GitHub Desktop.
Extend footer to take up the remainder of the viewport
var viewportHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
var footerDistanceFromTop = $('.footer').offset().top;
if (footerDistanceFromTop < viewportHeight) {
var footerHeight = viewportHeight - footerDistanceFromTop;
var footerMinHeight = parseInt($('.footer').css('min-height').split('px')[0]);
if (footerHeight > footerMinHeight) {
$('.footer').css('height', footerHeight + 'px');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment