Re: [csswg-drafts] [css-anchor-1] Can't anchor one popover to another (#8165)

> Btw, when there are multiple anchors with the same name, maybe we should return the last acceptable anchor instead of the first one (as we currently do)?

Oooh, yes, that sounds much better. I went for "first" just because I needed an answer and figured it was fairly arbitrary, but you're right that now that we allow elements at the same level to see each other, "last" actually solves a reasonable use-case.

-----

A little more precisely, the use-case I wanted was "anchor a sidebar note to its anchor in the main text, *or* below the preceding sidebar note, if they would overlap". So it would be like:

```
<style>
p:has(+ .sidebar-note) {
  anchor-name: --sidebar-anchor;
}
.sidebar-note {
  anchor-name: --sidebar-note;
  position: absolute;
  top: max(anchor(--sidebar-note bottom), anchor(--sidebar-anchor top));
}
</style>
<p>Some text
<aside class=sidebar-note>
<p>Some more text
<aside class=sidebar-note>
```

Now the layout is good regardless of how tall the paragraphs or notes are; the notes will try to anchor to their preceding paragraph, and if a previous note is too tall is taller than its corresponding paragraph, the next paragraph's note will get pushed down, cascading all the way down the document as required.

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


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

Received on Thursday, 4 May 2023 22:26:11 UTC