Currently, I am facing an issue with a toggle button on my website. When I click on the hamburger menu, the navigation bar does not show up even though the toggle feature is working perfectly fine. I have tried combining different sources to solve this problem since the underlying concept remains the same.
References:
https://www.example.com/toggle-button-video1
https://www.example.com/toggle-button-video2
* {
margin: 0;
padding: 0;
}
#toggle {
display: none;
}
.hambuger {
z-index: 1;
position: fixed;
width: 25px;
top: 20px;
left: 28px;
cursor: pointer;
}
.line {
display: block;
width: 100%;
height: 3px;
margin-bottom: 3px;
background-color: black;
}
.menu {
display: none;
width: 70px;
line-height: 1.7em;
margin: 40px;
}
.menu a {
display: block;
text-decoration: none;
color: black;
border: 1px grey solid;
}
#toggle:checked~.menu {
display: block;
}
<header class="content">
<label for="toggle" class="hambuger">
<input type="checkbox" id="toggle">
<span class="line"></span>
<span class="line"></span>
<span class="line"></span>
</label>
<nav class="menu">
<a href="#" class="active">Home</a>
<a href="#" class="active">About us</a>
<a href="#" class="active">History</a>
<a href="#" class="active">Contacts</a>
</nav>
</header>