Get "PHP 8 in a Nuthshell" (Soon includes PHP 8.4)
Amit Merchant

Amit Merchant

A blog on PHP, JavaScript, and more

How to disable scrolling the page behind a dialog element

Here’s how you can disable scrolling of the page behind a dialog element using :has() selector. Courtesy of this tweet by Adam Argyle.

html:has(dialog[open]) {
  overflow: hidden;
}

Was that useful? Consider leaving a

Tip

👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.

Comments?