Skip to content

Instantly share code, notes, and snippets.

@LukeberryPi
Last active August 7, 2024 11:43
Show Gist options
  • Save LukeberryPi/ea7eb3e954c182346a015f662ecc574f to your computer and use it in GitHub Desktop.
Save LukeberryPi/ea7eb3e954c182346a015f662ecc574f to your computer and use it in GitHub Desktop.
disable backdrop/background scroll when there is a modal/dialog open
/*
disable backdrop/background scroll when there is a modal/dialog open
this depends on having the open attribute on the dialog itself
more: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog
*/
dialog::backdrop { overflow: hidden; } body:has(dialog[open]) { overflow: hidden; pointer-events: none; } dialog[open] { pointer-events: auto; }
@LukeberryPi
Copy link
Author

disable backdrop/background scroll when there is a modal/dialog open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment