0

我 以这种方式编辑了Sticky Footer 脚本:

<script type="text/javascript">
    function stickyFooter(){
            jQuery("#stickyFooter").css({position: "absolute",top:($(window).scrollTop()+$(window).height()-$("#stickyFooter").height())+"px"});
    }

    function myStickyFooter(){
            jQuery("#stickyFooter").css({position: "absolute"});
            jQuery("#stickyFooter").animate({
            top:($(window).scrollTop()+$(window).height()-$("#stickyFooter").height())+"px"
          }, 2000, function() {
          });
    }

    jQuery(function(){

        myStickyFooter();
        jQuery(window)
            .scroll(stickyFooter)
            .resize(stickyFooter);
    });
</script>

因此,在 Firefox 上它工作正常;在 Chrome 或 Ie 上,它可以工作.. 相反:stickyFooter 从顶部到底部出现。为什么?非常感谢!

4

1 回答 1

2

这适用于所有浏览器。

解决方案:

您需要进行额外的工作来设置粘性页脚的初始位置,window.height()然后将其设置为动画window.height()-($('#footer').height())

于 2012-10-04T18:51:13.460 回答