After successfully creating a responsive menu that toggles with a hamburger icon at 1205px resolution, I encountered an issue. Once the hamburger icon is clicked and the dropdown menu opens, there seems to be no way to close it. I am looking to add an X button for users to easily close the menu once opened. Does anyone have suggestions on how this can be achieved?
html
<nav class="nav-box">
<label class="label" for="toggle">
☰
</label>
<input type="checkbox" id="toggle">
<ul class="f-cb">
<!-- my menu content -->
</ul>
</nav>
CSS
.label {
margin: 0 40px 0 0;
font-size: 26px;
line-height: 22px;
display: none;
color: #433F3F;
float: right;
width: 180px;
}
#toggle {
display: none;
}
/* menu */
@media only screen and (max-width: 1205px) {
#form1 > div:nth-child(3) > header > nav.nav-box > ul{
position: absolute;
background-color: white;
min-width: 150px;
box-shadow: 5px 16px 16px 8px rgba(0,0,0,0.4);
z-index: 1;
}
.label {
display: block;
cursor: pointer;
margin: 0 40px 0 0;
font-size: 28px;
line-height: 70px;
color: grey;
float: right;
width: 26px;
float: right;
}
#toggle:checked + .f-cb {
display: block !important;
}
}
@media only screen and (max-width: 760px) {
.label {
margin: 0 40px 0 0;
font-size: 28px;
line-height: 70px;
color: grey;
float: right;
width: 26px;
float: right;
}
}
I am attempting to add a close button 'X' within the dropdown menu that appears when clicking the hamburger icon. However, I am unsure of how to implement this. Any guidance would be appreciated.