繁体   English   中英

JQuery Scroll 在 Firefox 中不起作用

[英]JQuery Scroll doesn't work in firefox

我正在尝试创建一个滚动操作,我想在其中切换 .clone 类及其转换。 它在 Chrome 中正常工作,但在 Firefox 上无法正常工作。 有人能帮我吗?

CSS:

header {
   display: none;
   position: absolute;
   bottom: 0;
   width: 100%;
   height: 60px;
   padding: 20px;
   box-sizing: border-box;
   font-size: 20px;
   color: white;
}

header.clone {
   display: block;
   position: fixed;
   top: -65px;
   left: 0;
   right: 0;
   z-index: 999;
   transition: 0.2s top cubic-bezier(.3, .73, .3, .74);
   -webkit-transition: 0.2s top cubic-bezier(.3, .73, .3, .74);
   -moz-transition: 0.2s top cubic-bezier(.3, .73, .3, .74);
   -o-transition: 0.2s top cubic-bezier(.3, .73, .3, .74);
   -ms-transition: 0.2s top cubic-bezier(.3, .73, .3, .74);
   background: #3E3E3E;
 }

查询:

$(document).ready(function() {
    var $header = $("header");
    $clone  = $header.before($header.clone().addClass("clone"));

    $(document).on("scroll", function() {
        var fromTop = $("body").scrollTop();
        $("body").toggleClass("down",(fromTop > 800));
    });
});

像这样更改代码以更好地支持跨浏览器滚动。 使用window而不是¨body¨ ...

$(document).on("scroll", function() {
    var fromTop = $(window).scrollTop();
    // Rest of code

});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM