Last active
December 11, 2015 06:39
-
-
Save drainpip/4560823 to your computer and use it in GitHub Desktop.
Updates last section bottom padding inside a sticky footer design. This allows the top of the section to fit into the top of the viewport when the page would end at the top of the footer.
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
function updateHeight() { | |
if (($(window).height()) > $("section:last-child").height()) { | |
$("section:last-child").css("padding-bottom", $(window).height() - ($("section:last-child").height() + $("#footer").height() + 30) + "px"); // adjust the number for extra padding depending upon your site | |
} else { | |
$("section:last-child").css("padding-bottom", "0px"); | |
} | |
} | |
// call on DOM load | |
updateHeight(); | |
// call on window resize for portrait -> landscape | |
$(window).resize(function() { | |
updateHeight(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment