I have a div which I am using it as a container for my website menu items. When the width is below 992px using media queries I am hiding it. In the same time I am showing a menu-toggle which consist the followings:
<a id="menu-toggle" href="#" class="btn btn-primary btn-lg toggle">
<i class="fa fa-bars"></i>
</a>
Regarding my JQuery part I am just toggle the menu div every time the menu-toggle is clicked:
$('#menu-toggle').click(function(){
$('#menu').toggle('slow');
})
The issue that I am encountering is that after I toggle the element for the first time and hide it, jQuery overwrites my media query statement of display:none;
with her own. This results in having the menu div hidden when I resize back to a resolution over 992px. Here is my CSS code:
#menu-toggle {
margin-right: 15px;
margin-top: 128px;
position: absolute;
top: 0;
right: 0;
z-index: 1;
display: none;
}
#menu {
display: block;
border-bottom: 1px solid #F23A3A;
margin-bottom: 15px;
background-color: #FAFAFA;
}
@media (max-width: 991px) {
#menu-toggle {
display: inline-block;
}
#menu {
display: none;
}
}
It is a very annoying bug which I didn't figure it out how to solve it in a proper manner so any guidance is more than welcomed.