Last active
March 31, 2021 17:51
-
-
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.
This file contains hidden or 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
| /* 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