簡體   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