basic navbar css code example
Example 1: html navigation bar
<body>
<ul class="topnav">
<li><a class="active" href="Home.html">Home</a></li>
<li><a href="Page1.html">Page1</a></li>
<li><a href="Page2.html">Page2</a></li>
<li class="right" ><a href="About.html">About</a></li>
</ul>
</body>
ul.topnav {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
font-family: arial;
text-align: left;
width: 100%;
position: sticky;
top: 0;
}
ul.topnav li {float: left;}
ul.topnav li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
float: left;
font-size: 17px;
border-right: 1px solid #bbb;
}
ul.topnav li a:hover:not(.active) {
background-color: #ddd;
color: black;
}
ul.topnav li a.active {
background-color: #4CAF50;
}
ul.topnav li.right {
float: right;
}
@media screen and (max-width: 720px) {
ul.topnav li{
width: 100%;
}
ul.topnav a{
width: 100%;
}
}
Example 2: navbar in css
<nav>
<div class="nav-wrapper">
<a href="#" class="brand-logo">Logo</a>
<ul id="nav-mobile" class="right hide-on-med-and-down">
<li><a href="sass.html">Sass</a></li>
<li><a href="badges.html">Components</a></li>
<li><a href="collapsible.html">JavaScript</a></li>
</ul>
</div>
</nav>
Example 3: navbar examples
<nav class="navbar navbar-expand-md bg-dark
navbar-dark">
<a class="navbar-brand" href="#">Navbar</a>
<button
class="navbar-toggler" type="button"
data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse"
id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link"
href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link"
href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link"
href="#">Link</a>
</li>
</ul>
</div>
</nav>
Example 4: CSS Navigation bar
<ul>
<li><a href="default.asp">Home</a></li>
<li><a href="news.asp">News</a></li>
<li><a href="contact.asp">Contact</a></li>
<li><a href="about.asp">About</a></li>
</ul>