2011-10-12 104 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