Gewusst wie: Navigationsleiste mit Symbolen
Erfahren Sie, wie Sie mithilfe von CSS ein ansprechendes Navigationsmenü mit Symbolen erstellen.
Navigationsleiste mit Symbolen
Erstellen Sie eine responsive Navigationsleiste mit Symbolen
Schritt 1) HTML hinzufügen:
Beispiel
<!-- Load an icon library -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="navbar">
<a class="active" href="#"><i class="fa
fa-fw fa-home"></i>
Home</a>
<a href="#"><i class="fa fa-fw fa-search"></i> Search</a>
<a href="#"><i class="fa fa-fw fa-envelope"></i> Contact</a>
<a href="#"><i
class="fa fa-fw fa-user"></i> Login</a>
</div>
Schritt 2) CSS hinzufügen:
Beispiel
/* Style the navigation bar */
.navbar {
width: 100%;
background-color: #555;
overflow: auto;
}
/* Navbar links */
.navbar a {
float: left;
text-align: center;
padding: 12px;
color: white;
text-decoration: none;
font-size: 17px;
}
/* Navbar links on
mouse-over */
.navbar a:hover {
background-color: #000;
}
/* Current/active navbar link */
.active {
background-color: #04AA6D;
}
/* Add responsiveness - will automatically display the
navbar vertically instead of horizontally on screens less than 500 pixels */
@media screen and (max-width: 500px) {
.navbar a {
float: none;
display: block;
}
}
Tipp: Gehen Sie zu unserem CSS Navbar Tutorial , um mehr über Navigationsleisten zu erfahren.
Tipp: Wenn Sie eine Navigationsleiste erstellen möchten, die nur Symbole enthält, lesen Sie unser How To - Icon Bar Tutorial .