修复用Flexbox制成的NAV栏到页面顶部,但是当您滚动滚动时,请覆盖NAV栏
因此,我创建了一个带有Flex Box的导航栏。我目前周围有一个包装纸,以便可以将其固定在顶部。此功能正常,当您加载页面时,导航栏看起来不错。但是,当您向前滚动时,Navbar将被覆盖的页面界限。我将如何避免这种情况(我在下面附上图像以表明我的意思)。
滚动之前
“ rel =“ nofollow noreferrer”>滚动后
<div class="wrapper">
<nav>
<a href="index.html" class="logo"><img src="assets/logo.png"></a>
<div class ="nav-links">
<a href="#">About</a>
<a href="#">Portfolio</a>
<a href="#">Contact</a>
</div>
</nav>
</div>
nav {
background-color: rgba(0,0,0,.5); /*background color*/
height: 75px; /*height of navigation bar*/
display: flex; /*activates flexbox properties*/
align-items: center; /*uses flexbox to vertically center items*/
-webkit-backdrop-filter: blur(8px); /*blurs background*/
backdrop-filter: blur(8px); /*blurs background*/
padding-left: 20px;
padding-right: 20px;
justify-content: space-between;
}
.wrapper {
position: fixed;
width: 100%;
}
So I created a navigation bar with flex box. I currently have a wrapper around the so that I can make it fixed to the top. This functions correctly and when you load the page the nav bar looks fine. But when you scroll up past what would be the boundaries of the page the navbar becomes covered. How would I avoid this (I have attached images below to show what I mean).
<div class="wrapper">
<nav>
<a href="index.html" class="logo"><img src="assets/logo.png"></a>
<div class ="nav-links">
<a href="#">About</a>
<a href="#">Portfolio</a>
<a href="#">Contact</a>
</div>
</nav>
</div>
nav {
background-color: rgba(0,0,0,.5); /*background color*/
height: 75px; /*height of navigation bar*/
display: flex; /*activates flexbox properties*/
align-items: center; /*uses flexbox to vertically center items*/
-webkit-backdrop-filter: blur(8px); /*blurs background*/
backdrop-filter: blur(8px); /*blurs background*/
padding-left: 20px;
padding-right: 20px;
justify-content: space-between;
}
.wrapper {
position: fixed;
width: 100%;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
重置默认保证金和填充后似乎没有问题:
Seems to be no issue after resetting default margin and padding: