Re: [csswg-drafts] [css-anchor-position-1] Better reusability of anchor names (#9045)

> @xiaochengh
> Btw, if you want it anchored to the containing block, isn't it just the good old positioned layout (without anchor())?

Almost, but we couldn't use the `anchor-fallback`. Also, I can see cases where the `anchor-name` and `position: relative` could come from different sources, and when looking at the code, I would expect the `position: relative` to not break this case when both would be combined on one element.

> @tabatkins is it because the positioned element can trigger scrollbars on the containing block, and thus we don't have the "laid out strictly after" condition,

Ah, I see how the scrollbars on the containing block could prevent this from working, yes. If the scrollbars are the only case, I wonder if there is a way to solve this by assuming that they're absent only for this particular case? Not ideal, and I wish there could be a better solution, but I find having this kind of an exception better than requiring adding an extra wrapper or moving the element outside its container (this won't be always possible, like when the container is a `li`, `td`, when CSS relies on `nth-child` etc).

> Hm, re: "closest" tho, we probably want to allow both for "positioned element is inside of its anchor" and "positioned element is right after its anchor". I think both markup patterns are reasonable, depending on what you're doing.
> 
> It's probably okay to just conflate the two, and have the search first look for preceding siblings, then look for ancestors?

Thinking more about this — I like the idea of a `closest`, though agree that we'd need to think more about if we'd want to conflate siblings/ancestors. I would need to go through my use cases and see how they would behave with either.

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


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

Received on Thursday, 20 July 2023 19:05:57 UTC