I need to know how do I close this menu back up after the user clicks on a link or outside of it. My guess right now is that the best way would be to just uncheck the checkbox using js or jquery when the user clicks on a link or outside the menu background area, but I don't know much about javascript so I don't know how to do that lol. Code:
#mobilemenu {
position: fixed;
background-color: red;
background-size: cover;
top: 0px;
right: -50%;
height: 100%;
width: 50%;
z-index: 0;
transition: .5s;
}
#mobilemenu ul {
text-align: right;
margin-right: .5em;
margin-top: 3em;
list-style-type: none;
font-size: 1.25em;
}
#menuicon {
position: fixed;
z-index: 4;
right: 9px;
margin-top: 15px;
}
#menuicon i {
cursor: pointer;
background-color: white;
font-size: 12pt;
padding: 3px;
font-weight: bold;
color: black;
}
input[type="checkbox"]:checked~#mobilemenu {
transform: translateX(-100%);
}
input {
display: none;
}
<input type="checkbox" id="myInput">
<label for="myInput">
<nav id="menuicon">
<i>Menu</i>
</nav>
</label>
<aside id="mobilemenu">
<ul>
<li>
<a href="#">Link1</a>
</li>
<li>
<a href="#">Link2</a>
</li>
<li>
<a href="#">Link3</a>
</li>
<li>
<a href="#">Link4</a>
</li>
</ul>
</aside>