jQuery跟踪页面内容并相应调整大小

jQuery keeping track of page content and resize accordingly

本文关键字:调整 跟踪 jQuery      更新时间:2023-09-26

所以我有这个:

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()