I'm currently working on implementing a push menu on my website. The objective is to have the menu slide out from the left and overlap the current page content. I've written the code below but it doesn't seem to be functioning as expected. Can you spot any errors or oversights in my implementation?
CSS:
#menu {
display: none;
position: absolute;
top: 0;
left: -240px ;
position: fixed;
width: 240px;
height: 100%;
padding: 15px 25px;
margin: 0;
list-style: none;
background: #333;
z-index: 9999;
transition: all 0.3s ease;
-webkit-transition all 0.3s ease;
}
#menu a {
display: block;
color: #fff;
padding: 15px 0;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.animate {
transform: translateX(240px);
-webkit-transform: translateX(240px);
}
JavaScipt:
$(function() {
$('#toggle-menu').click(function() {
toggleMenu();
});
})(jQuery);
function toggleMenu() {
if ($('#menu').hasClass('animate')) {
$('#menu').removeClass('animate');
} else {
$('#menu').addClass('animate');
}
//$('#menu').toggleClass('animate');
}
HTML:
<div id="menu">
<ul>
<li><a href="#"> Home </a></li>
<li><a href="#"> Home </a></li>
<li><a href="#"> Home </a></li>
</ul>
</div>