Incorporated a simple off-canvas navigation system as outlined in this guide: . However, encountering an issue where scrolling within the menu is not possible, particularly problematic on mobile devices in landscape mode when the menu extends beyond the visible screen.
Exploring ways to prevent scrolling of content inside the page-wrapper
div while the navigation menu is open, allowing for scrolling within the off-canvas navigation without displaying a large scrollbar.
HTML:
<nav id="menu">
<a href="#menu" class="menu-link"></a>
<ul>
<span><a href="#">Title</a></span>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">Blog</a></li>
</ul>
</nav>
<div class="page-wrapper">
Body Content Here
</div>
CSS:
#menu {
position: fixed;
top: 0;
bottom: 0;
width: 13.755em;
right: -13.755em;
height: 100%;
-webkit-transform: translate(0px, 0px);
-moz-transform: translate(0px, 0px);
-o-transform: translate(0px, 0px);
-ms-transform: translate(0px, 0px);
transform: translate(0px, 0px);
-webkit-transition: 0.15s ease;
-moz-transition: 0.15s ease;
-o-transition: 0.15s ease;
transition: 0.15s ease;
}
#menu.active {
-webkit-transform: translate(-13.755em, 0px);
-moz-transform: translate(-13.755em, 0px);
-o-transform: translate(-13.755em, 0px);
-ms-transform: translate(-13.755em, 0px);
transform: translate(-13.755em, 0px);
}
.page-wrapper {
-webkit-transform: translate(0px, 0px);
-moz-transform: translate(0px, 0px);
-o-transform: translate(0px, 0px);
-ms-transform: translate(0px, 0px);
transform: translate(0px, 0px);
-webkit-transition: 0.15s ease;
-moz-transition: 0.15s ease;
-o-transition: 0.15s ease;
transition: 0.15s ease;
}
.page-wrapper.active {
-webkit-transform: translate(-13.725em, 0px);
-moz-transform: translate(-13.725em, 0px);
-o-transform: translate(-13.725em, 0px);
-ms-transform: translate(-13.725em, 0px);
transform: translate(-13.725em, 0px);
}
.menu-link {
position: absolute;
top: 15px;
left: -50px;
}
Javascript:
$(".menu-link").click(function(){
$("#menu").toggleClass("active");
$(".page-wrapper").toggleClass("active");
});