所以我有这个:
function fixContainer() {
$('div#mainContainer').css({
'min-height': $(document).height() - 104 // -104 is for a fixed header.. nvm that.
}).removeShadow().dropShadow({
'blur' : 5,
'opacity' : 0.2
});
}
效果很好,但有时将来会使用 ajax 和 jquery 模板加载内容。这不火。如何使 mainContainer 始终具有 100% 的高度?
忘记提及以下内容:
$(window).resize(function () {
fixContainer();
});
最佳答案
$(window).on('resize', function () {
fixContainer();
});
更新
对不起,我应该看到这个。 $(document).height()
在调整大小时保持不变。你想要 $(window).height()
关于javascript - jQuery 跟踪页面内容并相应地调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8997295/