.container {
container-type: scroll-state;
container-name: my-container;
}Using container scroll-state queries / notebook
Using container scroll-state queries
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
@container my-container scroll-state(scrollable: top) {
/* CSS rules go here */
}<a class="back-to-top" href="#" aria-label="Top of page">↑</a>
<article>
<h1>Reader with container query-controlled "back-to-top" link</h1>
<section>
<header>
<h2>This first section is interesting</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</header>
...
</section>
...
</article>