w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.52k stars 673 forks source link

[css-selectors] Add a :scrolling-element selector #5000

Open tomhodgins opened 4 years ago

tomhodgins commented 4 years ago

Hi everybody,

It would be nice if there was a CSS selector (e.g. :scrolling-element) that targeted the same element as document.scrollingElement refers to in the Document API. Not sure if this has been proposed before or not but I couldn't find any previous mentions here.

Thanks!

Loirooriol commented 4 years ago

Seems to me this could cause a cycle in quirks mode:

html, body:scrolling-element { overflow: auto }
body { overflow: visible }

If body is the :scrolling-element, then it gets overflow: auto. But then it becomes potentially scrollable, so it stops being the scrollingElement.

So then it stops matching :scrolling-element, and gets overflow: visible instead. But then it stops being potentially scrollable, so it becomes the scrollingElement again!

Maybe :scrolling-element could only work in non-quirks mode, but then it basically becomes :root:not(:quirks-mode). What's the use-case for that?