I have this HTML:
<button type="button" class="navbar-toggle" onclick="showNav();">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
I have this JS:
function showNav() {
document.getElementById("dropdown").classList.toggle("show");
}
and this CSS:
.navbar-toggle {
margin-top: 15px;
border: 0;
background-color: transparent;
cursor: pointer;
position: absolute;
z-index: 100;
padding: 0;
height: auto;
&:focus {
outline: 0;
}
.icon-bar {
background-color: #fff;
display: block;
width: 22px;
height: 2px;
border-radius: 1px;
background-color: #4F4644;
margin-bottom: 4px;
// &:before {
// content: "";
// height: 2px;
// background-color: #000000;
// width: 22px;
// margin-top: 5px;
// position: absolute;
// left: 0;
// top: -11px;
// }
// &:after {
// content: "";
// height: 2px;
// background-color: #000000;
// width: 22px;
// margin-top: 6px;
// position: absolute;
// left: 0;
// }
}
}
It looks like this:
Now, when I click on this, I am adding the .show
class and then it's showing the .dropdown-container
div which contain the menu items.
Now, sometimes it's not showing the .dropdown-container
container because of the gap between the toggle.
How can I implement the click event on the gap too?