Reputation: 35
This is the code for my navbar
(it has some more details, but it's just style so it doesn't matter I guess), and I cant find anything to make it fixed to the top of the page when I scroll down.
Also I'd like to do a smooth movement whenever I click any of the buttons, but
.container {
width: 80%;
margin: 0 auto;
}
header {
background: black;
}
header::after {
content: '';
display: table;
clear: both;
}
header h3 {
color: white;
float: left;
padding: 10px 0;
}
nav {
float: right;
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 70px;
padding-top: 18px;
position: relative;
}
<header>
<div class="container">
<h3>logo</h3>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#sobre">Sobre</a></li>
<li><a href="#servico">Serviços</a></li>
<li><a href="#BaseDeCusto">Base de Custo</a></li>
<li><a href="#faq">FAQ</a></li>
<li><a href="#contato">Contato</a></li>
</ul>
</nav>
</div>
</header>
Upvotes: 0
Views: 41
Reputation: 65
To do this, you want to give it the property:
header {
position: fixed;
}
Upvotes: 1