我想要实现的是与此类似的东西:http://www.thoughtspot.com/
我快到了!我无法复制的是导航在向上滚动时如何具有透明背景然后消失。
谁能帮我解决这个问题?
function hasScrolled() {
var st = $(this).scrollTop();
// Make sure they scroll more than delta
if(Math.abs(lastScrollTop - st) <= delta)
return;
// If they scrolled down and are past the navbar, add class .nav-up.
// This is necessary so you never see what is "behind" the navbar.
if (st > lastScrollTop && st > navbarHeight){
// Scroll Down
$('header').removeClass('nav-down').addClass('nav-up');
} else {
// Scroll Up
if(st + $(window).height() < $(document).height()) {
$('header').removeClass('nav-up').addClass('nav-down');
}
}
lastScrollTop = st;
}
有关完整代码,请查看我创建的 jsfiddle:
http://jsfiddle.net/s6mLJ/2257/
谢谢大家!
最佳答案
在这里,您只需向类添加不透明度,其余部分由 css transition 处理:
opacity: 0
我还添加了线性透明背景,使其与您的示例相似。
关于javascript - 向上滚动时的 jQuery 透明菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29401380/