Kuhusu kufanya: Sidebar uandaa
- Mpito wa mtaani Kifungu cha kina cha kina cha kina
- Mpito wa mtaani Kifungu cha kina cha kina cha kina
Mwita kuhusu kufanya sidebar uandaa kwa CSS.
Kuundua uandaa sidebar
Kichwa 1 - Ongeza HTML:
<!-- Sidebar --> <div class="sidebar"> <a class="active" href="#home">Nyumbani</a> <a href="#news">News</a> <a href="#contact">Contact</a> <a href="#about">About</a> </div> <!-- Page content --> <div class="content"> .. </div>
Second step - Add CSS:
/* Sidebar navigation menu */ .sidebar { margin: 0; padding: 0; width: 200px; background-color: #f1f1f1; position: fixed; height: 100%; overflow: auto; } /* Sidebar links */ .sidebar a { display: block; color: black; padding: 16px; text-decoration: none; } /* Active/current link */ .sidebar a.active { background-color: #04AA6D; color: white; } /* Link style on hover */ .sidebar a:hover:not(.active) { background-color: #555; color: white; } /* Page content. The value of the margin-left property should match the width property of the sidebar. */ div.content { margin-left: 200px; padding: 1px 16px; height: 1000px; } /* On screens with width less than 700 pixels, change the sidebar to a top bar */ @media screen and (max-width: 700px) { .sidebar { width: 100%; height: auto; position: relative; } .sidebar a {float: left;} div.content {margin-left: 0;} } /* In screens with width less than 400 pixels, display the sidebar vertically instead of horizontally */ @media screen and (max-width: 400px) { .sidebar a { text-align: center; float: none; } }
Vipengele vya vifaa
- Mpito wa mtaani Kifungu cha kina cha kina cha kina
- Mpito wa mtaani Kifungu cha kina cha kina cha kina