Belajar cara membuat menu panel samping (sidepanel) yang bisa diciutkan (collapse).
Contoh:
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> body { font-family: "Lato", sans-serif; } .sidepanel { width: 0; position: fixed; z-index: 1; height: 250px; top: 0; left: 0; background-color: #111; overflow-x: hidden; transition: 0.5s; padding-top: 60px; } .sidepanel a { padding: 8px 8px 8px 32px; text-decoration: none; font-size: 25px; color: #818181; display: block; transition: 0.3s; } .sidepanel a:hover { color: #f1f1f1; } .sidepanel .closebtn { position: absolute; top: 0; right: 25px; font-size: 36px; } .openbtn { font-size: 20px; cursor: pointer; background-color: #111; color: white; padding: 10px 15px; border: none; } .openbtn:hover { background-color:#444; } </style> </head> <body> <div id="mySidepanel" class="sidepanel"> <a href="javascript:void(0)" class="closebtn" >
Section Artikel
Contoh:
<div id="mySidepanel" class="sidepanel"> <a href="javascript:void(0)" class="closebtn" >
Contoh:
/* Menu sidepanel */.sidepanel { height: 250px; /* Tentukan tinggi */ width: 0; /* 0 width - ubah ini dengan JavaScript */ position: fixed; /* Stay ditempat */ z-index: 1; /* Stay diatas */ top: 0; left: 0; background-color: #111; /* Hitam */ overflow-x: hidden; /* Nonaktifkan horizontal scroll */ padding-top: 60px; /* Tempatkan konten 60px dari atas */ transition: 0.5s; /* Efek transisi 0,5 detik untuk meluncur di panel samping */} /* Link sidepanel */.sidepanel a { padding: 8px 8px 8px 32px; text-decoration: none; font-size: 25px; color: #818181; display: block; transition: 0.3s; } /* Saat Anda mengarahkan mouse ke link navigasi, ubah warnanya */.sidepanel a:hover { color: #f1f1f1; } /* Posisikan dan style tombol tutup (pojok kanan atas) */.sidepanel .closebtn { position: absolute; top: 0; right: 25px; font-size: 36px; margin-left: 50px; } /* Style tombol yang digunakan untuk membuka panel samping */.openbtn { font-size: 20px; cursor: pointer; background-color: #111; color: white; padding: 10px 15px; border: none; } .openbtn:hover { background-color: #444; }
Contoh:
/* Atur lebar sidebar menjadi 250px (tunjukkan) */function openNav() { document.getElementById("mySidepanel").style.width = "250px"; } /* Atur lebar sidebar menjadi 0 (sembunyikan) */function closeNav() { document.getElementById("mySidepanel").style.width = "0"; }