Recently, I managed to create a side navigation using the target function in CSS3. However, I am curious about how I can achieve the same result using jQuery without disrupting the layout. Any assistance would be greatly appreciated. Here is the code snippet:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html" charset="utf-8">
<style type="text/css">
@-webkit-keyframes nav {
from {left:-100px;opacity: 0;}
to {left:0px;opacity:1;}
}
@keyframes nav{
from {left:-100px;opacity: 0;}
to {left:0px;opacity:1;}
}
body {
margin:0;
padding:0;
background-color:#EFEBE9;
}
.navigate {
width:100%;
height:100px;
background-color:#FFF;
padding-bottom:1px solid #F6F6F6;
display:inline-block;
position:fixed;
}
.navigate > .navicon {
width:2em;
height:100px;
background-color:#1565C0;
color:#FFF;
font-size:4em;
text-align:center;
}
.navigate > .navicon > a {
text-decoration:none;
color:#FFF;
}
.menu {
display:none;
}
.menu:target {
display:table;
background-color:#0D47A1;
}
nav {
width:40%;
height:100%;
background-color:#1565C0;
position:absolute;
-webkit-animation-name:nav;
-webkit-animation-duration: 0.5s;
animation-name:nav;
animation-duration: 0.5s;
}
.closebtn {
color:#FFF;
font-size:2.5em;
margin:.3em;
float:right;
text-decoration:none;
}
.closebtn > a {
text-decoration:none;
font-size:1em;
color:#FFF;
}
</style>
</head>
<body>
<div class="navigate">
<div class="navicon" onclick="window.location.href='#menu';" >☰</div>
</div>
<div class="menu" id="menu">
<nav>
<div class="closebtn"><a href="">✖</a></div>
</nav>
</div>
</body>
</html>