Wie man erstellt: Seitenleiste mit Symbolen
Lernen Sie, wie man mit CSS eine Seiten导航菜单 mit Symbolen erstellt.
Wie man eine Seitenleiste mit Symbolen erstellt
Schritt 1 - Fügen Sie HTML hinzu:
<!-- Laden Sie die Symbolbibliothek --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <!-- Seitenleiste --> <div class="sidebar"> <a href="#home"><i class="fa fa-fw fa-home"></i> Startseite</a> <a href="#services"><i class="fa fa-fw fa-wrench"></i> Dienstleistungen</a> <a href="#clients"><i class="fa fa-fw fa-user"></i> Kunden</a> <a href="#contact"><i class="fa fa-fw fa-envelope"></i> Kontakt</a> </div>
Zweiter Schritt - Füge CSS hinzu:
/* Styles für die Seitenleiste - vollständige Höhe */ .sidebar { height: 100%; width: 160px; position: fixed; z-index: 1; top: 0; left: 0; background-color: #111; overflow-x: hidden; padding-top: 16px; } /* Stile für die Links in der Seitenleiste setzen */ .sidebar a { padding: 6px 8px 6px 16px; text-decoration: none; font-size: 20px; color: #818181; display: block; } /* Stile für die Links bei Mausüberfahrt setzen */ .sidebar a:hover { color: #f1f1f1; } /* Stile für den Hauptinhalt */ .main { margin-left: 160px; /* Gleiche Breite wie die Seitenleiste */ padding: 0px 10px; } /* Für kleine Bildschirme Media Queries hinzufügen (wenn die Bildschirmhöhe kleiner als 450 Pixel ist, kleinere Innenabstände und Schriftgröße hinzufügen) */ @media screen and (max-height: 450px) { .sidebar {padding-top: 15px;} .sidebar a {font-size: 18px;} }
相关页面
教程:CSS 导航栏
教程:如何创建图标导航栏