Is it possible to create a CSS overlay menu which freezes the scroll of the main content that it overlays? That is to say, when the menu overlay is active you can scroll the menu, but the not the content behind it.
I've created a menu overlay, but when you scroll through the menu, it scrolls the background content as well. Is there anyway to freeze the content behind when the menu overlay is active?
Here's the javascript I created for the menu
// open menu overlay / hide background content
function openNav() {
document.querySelector("nav").style.display = "block";
document.querySelector("body").style.background = "#999";
document.getElementById("btn-menuclose").style.display = "block";
document.getElementById("btn-menu").style.display = "none";
document.getElementById("background").style.display = "none";
}
//close menu overlay, reveal background content again
function closeNav() {
document.querySelector("nav").style.display = "none";
document.querySelector("body").style.background = "#fff";
document.getElementById("btn-menuclose").style.display = "none";
document.getElementById("btn-menu").style.display = "block";
document.getElementById("background").style.display = "block";
}