cecilia:webdesign:curtain_menu
This is an old revision of the document!
Table of Contents
Curtain menu
Maak van Wordpress sidebar 1 een curtain menu. Pas hierin het hoofdmenu toe via widget. De sidebar moet standaard verborgen staan. Met het onderstaande script kan de sidebar (het menu dus) uitgeklapt worden als een “curtain menu”.
HTML
Hamburgermenu
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">× SLUIT VENSTER</a>
Verschillende opties voor de Javascript, namelijk zichtbaar/onzichtbaar, Z-index of verschil in breedte of hoogte.
<script>
function openNav() {
document.getElementById("sidebar1").style.z-index = "100";
}
function closeNav() {
document.getElementById("sidebar1").style.z-index = "-100";
}
</script>
<script>
function openNav() {
document.getElementById("sidebar1").style.visibility = "visible";
}
function closeNav() {
document.getElementById("sidebar1").style.visibility = "hidden";
}
</script>
<script>
function openNav() {
document.getElementById("sidebar1").style.width = "80%";
}
function closeNav() {
document.getElementById("sidebar1").style.width = "0%";
}
</script>
<script>
function openNav() {
document.getElementById("sidebar1").style.height = "100%";
}
function closeNav() {
document.getElementById("sidebar1").style.height = "9%";
}
</script>
<script>
function openNav() {
document.getElementById("sidebar1").style.width = "275px";
}
function closeNav() {
document.getElementById("sidebar1").style.width = "0px";
}
</script>
CSS
hamburger wijzigt in X
<style>
.container {
display: inline-block;
cursor: pointer;
}
.bar1, .bar2, .bar3 {
width: 35px;
height: 5px;
background-color: #333;
margin: 6px 0;
transition: 0.4s;
}
.change .bar1 {
-webkit-transform: rotate(-45deg) translate(-9px, 6px);
transform: rotate(-45deg) translate(-9px, 6px);
}
.change .bar2 {opacity: 0;}
.change .bar3 {
-webkit-transform: rotate(45deg) translate(-8px, -8px);
transform: rotate(45deg) translate(-8px, -8px);
}
</style>
HTML
Hamburger icon
<div class="container" onclick="myFunction(this)"> <div class="bar1"></div> <div class="bar2"></div> <div class="bar3"></div> </div>
Javascript
Hamburger icon toggle class
<script>
function myFunction(x) {
x.classList.toggle("change");
}
</script>
cecilia/webdesign/curtain_menu.1644488581.txt.gz · Last modified: (external edit)
