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 に答える