background scrolling when menu is open

Hello, does anybody know, how to stop background scrolling when you open side menu? I've tried overflow-hidden but it does not work unless its on the main body, but then how would I make it work only when menu is open and closed? without it being always being hidden?
2 Replies
Anobjectn
Anobjectn9mo ago
generally if you want to stop scrolling in the background layer when a modal or a menu is open , you can try this if when your menu is open some dom has a specific class - e.g.
side-menu-open
side-menu-open
you can give the body or whatever container needed to have overflow:hidden but the key is using :has on an ancestor ... such as
body:has(.side-menu-open) .scrolling-container-if-not-body{overflow:hidden}
body:has(.side-menu-open) .scrolling-container-if-not-body{overflow:hidden}
, but often you want to overflow hidden the body while keeping your menu normal - in case its tall or inside a short window.
body:has(.side-menu-open){overflow:hidden}
body:has(.side-menu-open){overflow:hidden}
octavia0914
octavia0914OP9mo ago
ok thank you
Want results from more Discord servers?
Add your server