I want to make a menu up to a point simple with CSS3 and Javascript. My menu needs to have a "hamburger" and when clicking it needs to turn an "X". When you click on a link it also needs to close and the "X" will turn the "hamburger" again.
Below is what I already have.
$(document).ready(function(){
$('nav a').on('click', function(){
$('#menu').prop('checked', false);
});
});
*{ margin:0; box-sizing: border-box; overflow: hidden }
nav {
border: 1px solid #333;
display: flex;
flex-flow: column wrap;
right: -100%;
transition: right 400ms ease-in;
position: absolute;
width: 100%;
height:100%;
background:rgba(0,0,0,8);
opacity: 0.5;
line-height: 30px;
}
nav a{
text-decoration: none;
text-align: center;
font-size: 40px;
margin:3% 0%;
color:#fff;
font-family:sans-serif;
}
nav.open{
right: 0;
transition: right 400ms ease-in;
}
nav a:hover{
color:yellow;
}
label { display: block; padding:10px 10px 0px; text-align:left; }
#menu{display: none;
}
#menu:checked + nav {
right: 0;
}
<label for='menu'>MENU</label>
<input id='menu' type='checkbox'/>
<nav>
<a href='#!'>LINK 1</a>
<a href='#!'>LINK 2</a>
<a href='#!'>LINK 3</a>
<a href='#!'>LINK 4</a>
<nav>