繁体   English   中英

导航条在滚动条上的其他导航条下方

[英]Nav bar stick under other nav bar on scroll

我想问一下如何将导航栏粘贴在其他定位固定的导航栏下面?

实际上,当我向下滑动菜单时,我希望菜单底部的导航按钮停留在页面底部的菜单顶部导航之下

$(document).scroll(function () {
    var scroll = $(this).scrollTop();
    var topDist = $("").position();
    if (scroll > topDist.top) {
        $('.menu').css({"position":"absolute","bottom":"0"});
    } else {
        $('.menu').css({"position":"static","top":"80"});
    }
});

这是我所做的

我见过很多jquery插件,但没有发现它们有用-我的脚本编写能力不好,因此需要您的帮助,谢谢。

尝试包括菜单的height并更改为固定底部导航栏的位置:

$(window).scroll(function () {
    var mtHeight = $('.menu-top').height(),
        mbHeight = $('.menu-bottom').height(),
        scroll = $(this).scrollTop() + mtHeight + mbHeight,
        topDist = $(".page.two").position();
    if (scroll > topDist.top) {
        $('.menu-bottom').css({"position":"fixed","top":mtHeight});
    } else {
        $('.menu-bottom').css({"position":"absolute","top":"auto"});
    }
});

检查这个演示小提琴

暂无
暂无

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

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