Re: [csswg-drafts] [css-anchor-position-1] Behavior with transforms and offset-path (#8584)

Firstly, I'd just like to point out that there'd already be a similar issue regarding border-box vs. padding-box / content-box for fragmented content.
https://www.w3.org/TR/css-anchor-position-1/#anchor-pos
The spec currently says:
> If the [target anchor element](https://www.w3.org/TR/css-anchor-position-1/#target-anchor-element) is [fragmented](https://www.w3.org/TR/css-break-4/#fragment), the axis-aligned bounding rectangle of the [fragments](https://www.w3.org/TR/css-break-4/#box-fragment)' [border boxes](https://www.w3.org/TR/css-box-4/#border-box) is used instead.

Apart from that: yes, that's exactly what I'm thinking: Use the bounding box with transforms applied.

However: I realized that there's one concern here, about "anchor recalculation points". What if the anchor is resized or moved (and also why not change the transform at the same time?)?

```html
<!DOCTYPE html>
<style>
  #anchor {
    transform-origin: top left;
    scale: 2;
    anchor-name: --a;
    width: 50px;
    height: 50px;
    background: cyan;
  }
  #anchored {
    position: absolute;
    position-anchor: --a;
    width: 100%;
    height: 100%;
    border: dotted;
    box-sizing: border-box;
  }
</style>
<div style="position:relative;">
  <div id="anchor"></div>
  <div id="anchored" style="position-area:right;"></div>
</div>
```

Now do this:

```javascript
    anchor.style.width = "100px";
    anchor.style.scale = "1";
```

When an anchor is resized or moved, that should obviously affect any anchored elements, so any such bounding box that we calculated at the previous anchor recalculation point needs to be updated somehow. But transforms may have changed in the meantime as well. What to do?

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


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

Received on Monday, 26 May 2025 08:16:10 UTC