【发布时间】:2021-06-20 19:08:46
【问题描述】:
我制作了一个可以工作的导航栏,但我不能让它变得粘稠。我试过position: fixed 和top: 0 但他们做不到!帮助。他们使情况变得更糟。有人可以帮忙把它粘起来吗?
html {
scroll-behavior: smooth;
overflow-x: hidden;
}
body {
overflow-x: hidden;
background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.3)), url("background.png");
background-position: center top;
position: relative;
z-index: 1;
background-size: auto;
}
#first {
backdrop-filter: blur(20px);
width: 100%;
height: 100vh;
}
a:hover,
a:visited,
a:link,
a:active {
text-decoration: none;
color: white;
}
nav {
display: flex;
justify-content: space-between;
align-items: center;
min-height: 8vh;
font-family: 'Arial', sans-serif;
background-color: rgba(0, 0, 0, 0.5);
}
.logo {
color: rgb(212, 212, 212);
text-transform: lowercase;
letter-spacing: 5px;
font-size: 30px;
margin-left: 5vh;
font-family: "Minecraft Regular", sans-serif;
}
.nav-links {
display: flex;
justify-content: space-between;
width: 35%;
list-style: none;
}
.nav-links a {
color: rgb(212, 212, 212);
text-transform: uppercase;
text-decoration: none;
letter-spacing: 1px;
font-weight: bold;
font-size: 20px;
}
#register {
background-image: linear-gradient(to right, #6c7575, #5e8b94);
padding: 1.5vh;
border-radius: 25px;
margin-right: 5vh;
}
<nav>
<div class="logo">
<h4 id="logo-text">de_ducks2</h4>
</div>
<ul class="nav-links">
<li><a href="#first">Kezdőlap</a></li>
<li><a href="#ninth">Kapcsolat</a></li>
<li><a href="i.html" id="register">Regisztráció</a></li>
</ul>
<div class="randomfaszaanimation">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
</div>
</nav>
其他部分用于移动视图。如果它们可以对粘性工作产生影响,我也会发送它们。整个网站都可以在这里找到:https://zsombitech.github.io/DeDucks2-Website/。
感谢您的帮助!
【问题讨论】: