Last active
July 17, 2020 23:11
-
-
Save corypina/ce124115238f0f3a78943cbb0ed7a5ad to your computer and use it in GitHub Desktop.
Min-height for main content area
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
// Calculate | |
(function ($) { | |
// Bind to the resize event of the window object | |
$(window) | |
.on("resize", function () { | |
let wpadmin; | |
if ($("#wpadminbar")) { // in case WP admin bar is present | |
wpadmin = $("#wpadminbar").height(); | |
} else { | |
wpadmin = 0; | |
} | |
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) | |
$(".content").css( | |
"min-height", | |
screen - (footer + header + wpadmin) | |
); | |
// Invoke the resize event immediately | |
}) | |
.resize(); // run resize immediately | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment