Re: [csswg-drafts] [css-anchor-position] Make anchor-center work without position-anchor (#10366)

Not generally, no. An author can refer to multiple different anchor elements on the same positioned element, so inference from "they've only mentioned one anchor name so far" is fragile.

Learning to reach for `position-anchor` early is a good reflex anyway, as when you *are* only using a single anchor it makes your other properties since you can omit the anchor name:

```css
.anchored {
 position: absolute;
 position-anchor: --foo;
 left: anchor(50%);
 top: anchor(bottom);
 justify-self: anchor-center;
}
```

Tho note that these styles create overflow - the inset-modified containing block's left edge is right at the anchor's center, so by anchor-centering you are *by definition* overflowing the IMCB. You probably just wanted to write this instead, which also means you'll be setting `position-anchor` anyway:

```css
.anchored {
 position: absolute;
 position-anchor: --foo;
 inset-area: bottom;
}
```

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


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

Received on Friday, 24 May 2024 18:25:25 UTC