[英]How can I make my navigation appear on a certain section of my webpage?
How can I make it disappear on #part1
section then make the navigation bar appear on section #part2,3,4
? 如何使它消失在
#part1
部分,然后使导航栏出现在#part2,3,4
部分?
I tried changing the value from 301 to 0 but the nav bar was still there. 我尝试将值从301更改为0,但导航栏仍然存在。 On
#part1
I don't want the navigation bar to be visible. 在
#part1
我不希望导航栏可见。 However, on section 2,3,4 which is known as #part2, #part3, and #part4
I want the navigation to appear. 但是,在被称为
#part2, #part3, and #part4
第2、3、4节中#part2, #part3, and #part4
我希望导航出现。
Here is an example of the concept that I'm trying to get my portfolio to look like in terms of the navigation bar. 这是我要使我的投资组合在导航栏上看起来像的概念的示例 。
$(window).on("scroll", function() {
if ($(this).scrollTop() < 0) {
$(".navbar").show();
} else {
$(".navbar").slideUp(400);
}
Add var windowHeight = $(window).height();
添加
var windowHeight = $(window).height();
before the function and change < 0
into > windowHeight
函数之前,将
< 0
更改为> windowHeight
So it will show when you've scrolled down for 100vh 当您向下滚动100vh时会显示
Also add a display: none property to .navbar 还添加一个显示:.navbar的none属性
So it will hide the navbar initially. 因此,它将最初隐藏导航栏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.