JavaScript
Article
By Sam Deering

jQuery Set Minimum Height for Page Content

By Sam Deering

jQuery code snippet which set a minimum height for a page content area based on the size of the window. This could be used to set the footer of a page to always be on the bottom within the page content area no matter what size the window is. It could be used with Capturing window resize so that it resizes automatically when the user resizes the browser window.

--ADVERTISEMENT--

//sets the minimum height for the content area of the page
minWrapperHeight: function()
{
    var wrapperElem = $('#wrapper');
    //padding+offset+header+footer
    var offset = wrapperElem.height()-wrapperElem.outerHeight()-$('header').height()-$('footer').height()-$('#wrapper').offset()['top'];
    console.log($(window).height() + ' - ' + offset + ' = ' + ($(document).height()-offset));
    wrapperElem.height($(window).height()+offset); //offset is negative
}
Recommended
Sponsors
The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account