Sticky Header after scrolling down

前端 未结 10 1229
野性不改
野性不改 2020-11-27 11:19

I saw this sticky header on this website: http://dunked.com/ (no longer active, view archived site)

When you scroll down the sticky header comes down from t

10条回答
  •  旧时难觅i
    2020-11-27 12:12

    This was not working for me in Firefox.

    We added a conditional based on whether the code places the overflow at the html level. See Animate scrollTop not working in firefox.

      var $header = $("#header #menu-wrap-left"),
      $clone = $header.before($header.clone().addClass("clone"));
    
      $(window).on("scroll", function() {
        var fromTop = Array(); 
        fromTop["body"] = $("body").scrollTop();
        fromTop["html"] = $("body,html").scrollTop();
    
    if (fromTop["body"]) 
        $('body').toggleClass("down", (fromTop["body"] > 650));
    
    if (fromTop["html"]) 
        $('body,html').toggleClass("down", (fromTop["html"] > 650));
    
      });
    

提交回复
热议问题