[英]can anyone help me figure out why can't I change my sticky top navbar to left? CSS
I wanted to change the position of my navbar on my portfolio but after many tries it just doesn't work for me, either it completely vanishes or stays in the same place.我想在我的投资组合中更改我的导航栏的 position 但经过多次尝试它对我不起作用,它要么完全消失,要么留在同一个地方。 Could anyone look into the code and tell me what to modify?任何人都可以查看代码并告诉我要修改什么吗? Down below I'm posting my code with top navbar.下面我用顶部导航栏发布我的代码。
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>
I'd like to keep my hover animation but now come to think of it, the bar could be on the side now.我想保留我的 hover animation 但现在想想,酒吧现在可能在一边。 I'll fix that myself.我会自己解决的。
If I understood correctly the problem just add the following to your css:如果我理解正确,只需将以下内容添加到您的 css 中:
* {
margin: 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.