JSFiddle - React, Tailwind, and code Playground
by wutyeetun87
HTML
<h1>Testing Testing</h1>
<a id="nav-toggle" href="#"><span></span></a>
<div id="slideout">
<div id="slidecontent">
Yar, there be menu herre!
</div>
</div>
CSS
body {
overflow-x: hidden;
}
#slideout {
background: #666;
position: absolute;
width: 280px;
height: 100%;
top: 0;
left:-220px;
padding-right: 20px
}
h1 { margin-top: 60px; }
#slidecontent {
float:left;
margin-top: 50px;
}
#nav-toggle {
position: absolute;
top: 0;
left: 0;
z-index: 999;
}
#nav-toggle { cursor: pointer; padding: 10px 35px 16px 0px; }
#nav-toggle span, #nav-toggle span:before, #nav-toggle span:after {
cursor: pointer;
height: 1px;
width: 25px;
background: white;
position: absolute;
display: block;
content: '';
}
#nav-toggle span:before {
top: -10px;
}
#nav-toggle span:after {
bottom: -10px;
}
#nav-toggle span, #nav-toggle span:before, #nav-toggle span:after {
transition: all 500ms ease-in-out;
}
#nav-toggle.active span {
background-color: transparent;
}
#nav-toggle.active span:before, #nav-toggle.active span:after {
top: 0;
}
#nav-toggle.active span:before {
transform: rotate(45deg);
}
#nav-toggle.active span:after {
transform: rotate(-45deg);
}
JavaScript
$(function () {
$("#nav-toggle").toggle(function () {
$('#slideout').animate({left:'0px'}, {queue: false, duration: 500});
}, function () {
$('#slideout').animate({left:'-220px'}, {queue: false, duration: 500});
});
});
document.querySelector( "#nav-toggle" )
.addEventListener( "click", function() {
this.classList.toggle( "active" );
});