默认情况下,菜单出现在每一页上。我想让菜单不出现在第一页上。我做了以下事情:
$('#fullpage').fullpage({
verticalCentered: true,
scrollingSpeed: 600,
css3: true,
onLeave: function(index, nextIndex, direction){
if (index == 2 && direction == 'up'){
$('#menu').css('visibility','hidden');
}
},
afterLoad: function(anchorLink, index){
if (index == 2){
$('#menu').css('visibility','visible');
}
}
现在当我滚动到第二页时菜单出现,当我滚动到第一页时菜单隐藏。但是这样菜单就不是第二页的一部分,它只是根据位置改变可见性。
我想要以下内容:当它滚动到第一页时,菜单应该停留在第二页。相反,当它从第一页滚动到第二页时,菜单应该在第二页。
附言现在在 html 中,菜单被放置在整个页面包装器之外。
附言该网站将有两个以上的页面,我想将菜单附加到窗口的顶部。
P.P.P.S.我已经做了我想做的。但效果不好 - http://jsfiddle.net/a3dw6p4w/
最佳答案
I want the following: when it scrolls to the first page, the menu should stay on the second.
为菜单使用固定位置。这是 CSS 的问题,而不是 jQuery 的问题:
#menu{
position:fixed;
top: 30px;
left: 30px;
z-index:999;
}
关于javascript - fullpage.js 如何将固定菜单附加到第二部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26458006/