Wie man erstellt: Navigationsleiste mit Symbolen
Lernen Sie, wie Sie eine responsive Navigationsleiste mit Symbolen mit CSS erstellen.
Navigationsleiste mit Symbolen
Erstellen Sie eine responsive Navigationsleiste mit Symbolen
Schritt 1 - Fügen Sie HTML hinzu:
Laden Sie eine Symbolbibliothek <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> Startseite</a> <a href="#"><i class="fa fa-fw fa-search"></i> Suchen</a> <a href="#"><i class="fa fa-fw fa-envelope"></i> Kontakt</a> <a href="#"><i class="fa fa-fw fa-user"></i> Login</a> </div>
Zweiter Schritt - Fügen Sie CSS hinzu:
/* Set the style of the navigation bar */ .navbar { width: 100%; background-color: #555; overflow: auto; } /* Navigation bar link style */ .navbar a { float: left; text-align: center; padding: 12px; color: white; text-decoration: none; font-size: 17px; } /* Navigation bar link style on hover */ .navbar a:hover { background-color: #000; } /* Current/active navigation bar link */ .active { background-color: #04AA6D; } /* Hinzufügen von Responsivität - Die Navigationsleiste wird auf Bildschirmen mit einer Breite von weniger als 500 Pixeln automatisch vertikal angezeigt, anstatt horizontal. Hinzufügen von Responsivität - Die Navigationsleiste wird auf Bildschirmen mit einer Breite von weniger als 500 Pixeln automatisch vertikal angezeigt, anstatt horizontal. */ @media screen and (max-width: 500px) { .navbar a { float: none; display: block; } }
相关页面
教程:CSS 导航栏
教程:如何创建图标导航栏