使用 jQuery Waypoints 插件的粘性导航栏
我已经使用 jQuery Waypoints 插件创建了一个粘性导航,但是当选择一个部分时,我无法让导航选项始终突出显示。
在我的示例中,您将看到菜单项仅在该部分位于范围内时才处于“活动”状态,并且这会根据视口的高度而变化,这是 Waypoints 默认情况下的工作方式:
http://jsfiddle.net/keith/v6vuN/2/ (或全屏版本:http://jsfiddle.net/keith/v6vuN/2/embedded /result/)
我希望菜单项始终突出显示,即使该部分不在范围内。
例如,如果我位于“精选”部分并且“联系人”可见,即使浏览器窗口的高度无法滚动到整个部分,我仍然希望突出显示菜单选项。
这有道理吗?我不想只是在各部分之间或页面底部添加大量填充/边距以使其更长。
I've created a sticky nav using the jQuery Waypoints plugin, but I am having trouble getting the nav options to always highlight when a section is chosen.
In my example you'll see that a menu item is only "active" when the section is within the range, and this changes based on the height of the viewport, which is the way Waypoints is supposed to work by default:
http://jsfiddle.net/keith/v6vuN/2/
(or fullscreen version: http://jsfiddle.net/keith/v6vuN/2/embedded/result/)
I'd like the menu items to always highlight, even if the section isn't within range.
For example, if I'm on the "Featured" section and "Contact" is visible, I'd still like the menu option to highlight even if the browser window's height can't scroll to the entire section.
Does that make sense? I'd rather not just add a lot of padding/margin between the sections or at the bottom of the page to make it longer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这一部分中,将:更改
为:
0 偏移量是距屏幕顶部 0 像素,而 50% 将使其在中间点触发。相应地调整,但 50% 应该这样做。
In this part, change:
To:
0 offset is 0px from the top of the screen while 50% will make it fire at the halfway point. Adjust accordingly, but 50% should do it.