Skip to content

Instantly share code, notes, and snippets.

@corypina
Last active March 31, 2021 17:51
Show Gist options
  • Select an option

  • Save corypina/0ed24ada2bf7171ae9d594822af7534b to your computer and use it in GitHub Desktop.

Select an option

Save corypina/0ed24ada2bf7171ae9d594822af7534b to your computer and use it in GitHub Desktop.
Keep the footer pinned to the bottom of the page, even when content isn't tall enough.
/* Be sure to set your element queries according
to what you actually have in the document! */
(function ($) {
// Bind to the resize event of the window object
const doResize = () => {
let wpadmin = 0;
if ($("#wpadminbar").length) { // in case WP admin bar is present
wpadmin = $("#wpadminbar").height();
}
let footer = $("footer").height();
let header = $("header").height();
let screen = $(window).height();
// Set min-width of main element to:
// screen height - (footer, header, and maybe admin bar)
$(".fl-page-content").css(
"min-height",
screen - (footer + header + wpadmin)
);
}
$(window).on("resize",doResize);
$(document).ready(doResize);
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment