【发布时间】:2021-03-18 18:45:04
【问题描述】:
我想更改我的导航栏在我的投资组合中的位置,但经过多次尝试后它对我不起作用,要么完全消失,要么留在同一个地方。任何人都可以查看代码并告诉我要修改什么吗? 在下方,我正在使用顶部导航栏发布我的代码。
css
body {
margin: 0;
width: 100%;
font-family: "Quicksand", sans-serif;
background: #dbdbdb;
z-index: 1;
}
.container {
font-weight: 750;
width: 100%;
color: white;
background-color: #b3b3b3;
z-index: 5;
overflow: hidden;
position: fixed;
position: -webkit-sticky;
top: 0px;
margin-bottom: 20px;
white-space: nowrap;
top: 0;
background-image: linear-gradient(bottom, #dbdbdb 2%, #b3b3b3 60%);
background-image: -moz-linear-gradient(bottom, #dbdbdb 2%, #b3b3b3 60%);
}
header {
background-color: #b3b3b3;
z-index: 5;
}
header::after {
content: "";
display: table;
clear: both;
}
.logo {
float: left;
padding: 10px 0;
z-index: 5;
}
img {
float: left;
width: 90px;
height: 70px;
padding-top: 10px;
}
nav {
float: right;
top: 0;
margin-right: 8%;
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 70px;
padding-top: 23px;
position: relative;
}
nav a {
color: rgb(80, 80, 80);
text-decoration: none;
text-transform: uppercase;
font-size: 13px;
display: inline-block;
}
nav a:hover {
color: rgb(140, 140, 140);
}
nav a::before {
content: "";
display: block;
height: 5px;
background-color: rgb(140, 140, 140);
position: absolute;
top: 0;
width: 0%;
transition: all ease-in-out 250ms;
}
nav a:hover::before {
width: 100%;
}
html
<header>
<div class="container">
<nav>
<ul>
<li><a href="#history">.history</a></li>
<li><a href="#">.aboutme</a></li>
<li><a href="#">.skills</a></li>
<li><a href="#">.aspirations</a></li>
</ul>
</nav>
</div>
</header>
我想保留悬停动画,但现在想一想,栏现在可能在一边。我会自己解决。
【问题讨论】: