1

问题:

我正在使用 jQuery 将页脚与页面底部对齐。它适用于 FF,但 IE、Chrome 和 Safari 将页脚向下推约 50-100 像素。

你自己看:

查看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>

我的问题:

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

4

1 回答 1

1

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

希望这可以帮助。

于 2012-04-04T17:03:23.317 回答