I'm currently working on creating a unique full screen overlay navigation menu, but I've encountered some challenges along the way. My goal is to have the overlay appear underneath my transformed hamburger menu and hide all other elements on the webpage. I've reached a point where this working prototype can be viewed (best in mobile view). I would greatly appreciate any assistance in achieving this desired outcome. Below is the jQuery code snippet I am using to toggle the state of the hamburger menu:
Jquery
$("#mobile-menu").click(function () {
$(".icon").toggleClass("close");
var x = document.getElementsByClassName("overlay")[0];
if ($(".icon").hasClass("close")) {
x.style.display = "block";
$("body").addClass("modal-open");
} else {
x.style.display = "none";
$("body").removeClass("modal-open");
}
});
CSS
.overlay {
height: 100vh;
width: 100%;
margin: 0px;
display: none;
overflow: hidden;
}
Desired result : The overlay covers the body but remains under the hamburger menu
I have searched for solutions related to this issue, but most examples involve an overlay menu with its own closing button. In my case, I need the closing button to remain fixed and on top of the overlay.