我想问一下如何将导航栏粘贴在其他固定定位的导航栏下面?
实际上,当我向下滑动菜单时,我希望菜单底部的导航按钮停留在页面底部的菜单顶部导航下面
$(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"});
}
});
检查这个演示小提琴
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句