Skip to content

Instantly share code, notes, and snippets.

@sjmacneil
Created April 21, 2015 21:22
Show Gist options
  • Save sjmacneil/9a37a062868a82a0f731 to your computer and use it in GitHub Desktop.
Save sjmacneil/9a37a062868a82a0f731 to your computer and use it in GitHub Desktop.
Make any footer stick to the bottom if there is room below the element. It works on page load and browser resize. Source: http://foundation.zurb.com/forum/posts/629-sticky-footer
// Make sure you do not put padding on the class/id being used in the JavaScript below
$(window).bind('load', function() {
var footer = $('footer'),
position = footer.position(),
height = $(window).height();
height = (height - position.top) - footer.height();
if (height > 0) {
footer.css('margin-top', height + 'px');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment