jQuery代码段, 根据窗口的大小设置页面内容区域的最小高度 。 这可以用来将页面的页脚设置为始终位于页面内容区域的底部,而不管窗口的大小如何。 它可以与捕获窗口调整大小一起使用,以便在用户调整浏览器窗口大小时自动调整大小。
//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
}
From: https://www.sitepoint.com/jquery-set-minimum-height-page-content/
本文介绍了一段使用jQuery实现的功能,该功能可以根据窗口大小动态调整页面内容区域的高度,确保页脚始终保持在页面底部。通过计算窗口高度、外边距、头部和底部元素的高度以及元素的位置偏移,实现页面布局的自适应。

2874

被折叠的 条评论
为什么被折叠?



