粘滞页脚(jQuery)不会完全对齐页面底部

时间:2011-10-12 03:11:38

标签: jquery footer sticky

问题:

我正在使用jQuery将页脚与页面底部对齐。它适用于FF,但IE,Chrome和Safari将页脚缩小了约50-100px。

亲眼看看:

查看www.directsponsor.org的页脚,查看问题的实例。

代码:

<script type="text/javascript">

    jQuery.noConflict();

    jQuery(document).ready(function($){
        matchHeight();
    function matchHeight() {
        var mainHeight = $("#wrapper").outerHeight() - $("#header").outerHeight() - $("#leader").outerHeight() - $("#footer").outerHeight() - parseInt($("#footer").css("margin-top")) - 1 - parseInt($("#main").css("padding-top"))- parseInt($("#main").css("padding-bottom"));
        var mainReal = $("#main").outerHeight(true);

        if ((mainHeight + 1 + parseInt($("#main").css("padding-top")) + parseInt($("#main").css("padding-bottom"))) > mainReal) {
            $('#main').height(mainHeight);
        }
    }
    $(window).resize(matchHeight);
});

</script>

我的问题:

是什么导致页脚下沉到页面底部?

1 个答案:

答案 0 :(得分:1)

试试这个:http://www.codicode.com/art/the_best_sticky_footer.aspx 此代码也使用jQuery,并在所有浏览器上都能正常运行。

希望这会有所帮助。