Re: [csswg-drafts] [css-anchor-1] Could anchor positioning work for defining the targets of sticky elements? (#8905)

> Another potential use-case for this — accumulating the sticky elements, like when headers of different heights are stacking together.

This functionality has been requested before, for example in https://github.com/w3c/csswg-drafts/issues/2496#issuecomment-1002312635.

I like the syntax you proposed, but am concerned when you have multiple of the same elements that need to stick.

```html
<main>
<h1></h1>
<h2 id="first"></h2>
<h2 id="second"></h2>
<h3></h3>
<h2 id="last"></h2>
</main>
```

If you have the h3’s stick against the h2’s, and the h2’s against the h1 you basically want an h2 that is about to get stuck to push an earlier h2 that was stuck out of view, instead of overlapping it _(as they currently would do)_. In the snippet above, `#second` should push `#first` out of view.

Furthermore, the `#last` h2 would need to push not only the preceding h2 `#second` out of view, *but also the h3*. If they would stack against each other, the `#last` h2 would be stuck against the h1, yet the other h2’s and the h3 would still be visible underneath.

-- 
GitHub Notification of comment by bramus
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8905#issuecomment-1652561416 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 26 July 2023 22:05:21 UTC