繁体   English   中英

向下滚动时修复顶部的导航栏

[英]Fix nav bar on top on scroll down

我试图实现类似于这里的东西

但对我来说,它不会在向下滚动时固定在顶部。请提供任何示例或资源来实现此功能。

     .features-switcher.fixed:after,
      {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
        position: fixed;
        z-index: 101;
        width: 100%;
        height: 65px;
        top: 0;
        left: 0;
        opacity: 1
    }

对于我的导航栏 div 类features-switcher

        $(window).scroll(function () {
            console.log("scrolled down");
            console.log($(window).scrollTop());
            if ($(window).scrollTop() > 150) {
                $('features-switcher').css('top', 0);
            }
        }
        );    

你缺少一个.

$('features-switcher').css('top', 0);

应该...

$('.features-switcher').css('top', 0);

暂无
暂无

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

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