Membuat sidenav / bilah menu samping
Demo Bilah Sisi
Klik tombol menu dibawah ini untuk membuka bilah sisi dan klik tanda silang untuk menutup.
Klik tombol menu dibawah ini untuk membuka bilah sisi dan klik tanda silang untuk menutup.
☰
HTML
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<a class='link-menu' href="#">Tentang</a>
<a class='link-menu' href="#">Layanan</a>
<a class='link-menu' href="#">Partner</a>
<a class='link-menu' href="#">Kontak</a>
</div>
<div id="main">
<h2>Demo Bilah Sisi</h2>
<p>Klik tombol menu dibawah ini untuk membuka bilah sisi dan klik tanda silang untuk menutup.</p>
<span style="font-size:30px;cursor:pointer" onclick="openNav()">☰ </span>
</div>
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<a class='link-menu' href="#">Tentang</a>
<a class='link-menu' href="#">Layanan</a>
<a class='link-menu' href="#">Partner</a>
<a class='link-menu' href="#">Kontak</a>
</div>
<div id="main">
<h2>Demo Bilah Sisi</h2>
<p>Klik tombol menu dibawah ini untuk membuka bilah sisi dan klik tanda silang untuk menutup.</p>
<span style="font-size:30px;cursor:pointer" onclick="openNav()">☰ </span>
</div>
CSS
<style>
.sidenav {
font-family: "Lato", sans-serif;
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #ddd;
overflow-x: hidden;
transition: 0.5s;
padding-top: 60px;
box-shadow: 1px 2px 4px #999;
border-right: 1px solid #999
}
.sidenav a {
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 16px;
color: #777;
display: block;
transition: 0.3s;
}
.sidenav a.link-menu{
border-bottom:1px dotted #999;
}
.sidenav a.link-menu:hover{
background:#ccc
}
.sidenav a:hover {
color: #555;
background: #ccc;
}
.sidenav .closebtn {
position: absolute;
top: 0;
right: 25px;
font-size: 36px;
margin-left: 50px;
}
#main {
transition: margin-left .5s;
padding: 16px;
}
@media screen and (max-height: 450px) {
.sidenav {padding-top: 15px;}
.sidenav a {font-size: 18px;}
}
</style>
.sidenav {
font-family: "Lato", sans-serif;
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #ddd;
overflow-x: hidden;
transition: 0.5s;
padding-top: 60px;
box-shadow: 1px 2px 4px #999;
border-right: 1px solid #999
}
.sidenav a {
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 16px;
color: #777;
display: block;
transition: 0.3s;
}
.sidenav a.link-menu{
border-bottom:1px dotted #999;
}
.sidenav a.link-menu:hover{
background:#ccc
}
.sidenav a:hover {
color: #555;
background: #ccc;
}
.sidenav .closebtn {
position: absolute;
top: 0;
right: 25px;
font-size: 36px;
margin-left: 50px;
}
#main {
transition: margin-left .5s;
padding: 16px;
}
@media screen and (max-height: 450px) {
.sidenav {padding-top: 15px;}
.sidenav a {font-size: 18px;}
}
</style>
SCRIPT
<script>
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.getElementById("main").style.marginLeft = "250px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("main").style.marginLeft= "0";
}
</script>
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.getElementById("main").style.marginLeft = "250px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("main").style.marginLeft= "0";
}
</script>