2011-10-12 137 views
1

問題:

我正在使用jQuery將頁腳對齊到頁面底部。它適用於FF,但IE,Chrome和Safari將頁腳降低約50-100px。粘性頁腳(jQuery)將不會完全對齊頁面底部

見自己:

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

試試這個:http://www.codicode.com/art/the_best_sticky_footer.aspx 這段代碼也使用jQuery,並且在所有瀏覽器上都完美地工作。

希望這有助於。

+1

最後,一個跨瀏覽器的解決方案。如果遇到任何問題,我會重新報告。謝謝。 –

+0

您需要改進此答案才能不依賴於您網站的鏈接。否則它將被刪除。 – ThiefMaster