Pelajari cara membuat menu navigasi bawah dengan CSS.
Section Artikel
Contoh:
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> body { margin: 0; font-family: Arial, Helvetica, sans-serif; } .navbar { overflow: hidden; background-color: #333; position: fixed; bottom: 0; width: 100%; } .navbar a { float: left; display: block; color: #f2f2f2; text-align: center; padding: 14px 16px; text-decoration: none; font-size: 17px; } .navbar a:hover { background: #f1f1f1; color: black; } .navbar a.active { background-color: #4CAF50; color: white; } .main { padding: 16px; margin-bottom: 30px; } </style> </head> <body> <div class="navbar"> <a href="#home" class="active">Home</a> <a href="#news">News</a> <a href="#contact">Contact</a> </div> <div class="main"> <h1>Bar Navigasi Bawah</h1> <p>Ini teks ini teks ini teks.</p> </div> </body> </html>
Langkah 1) Tambahkan HTML
Contoh:
<div class="navbar"> <a href="#home" class="active">Home</a> <a href="#news">News</a> <a href="#contact">Contact</a> </div>
Langkah 2) Tambahkan CSS
Contoh:
/* Tempatkan bar navigasi di bagian bawah halaman, dan tempelkan */ .navbar { background-color: #333; overflow: hidden; position: fixed; bottom: 0; width: 100%; } /* Beri Style link di dalam bar navigasi*/ .navbar a { float: left; display: block; color: #f2f2f2; text-align: center; padding: 14px 16px; text-decoration: none; font-size: 17px; } /* Ubah warna link saat mengarahkan kursor */ .navbar a:hover { background-color: #ddd; color: black; } /* Tambahkan warna ke link ive/current */ .navbar a.active { background-color: #4CAF50; color: white; }