[csswg-drafts] [css-anchor-1] Allow anchoring to a particular grid area of the target element (#8898)

kizu has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-anchor-1] Allow anchoring to a particular grid area of the target element ==
Read https://github.com/w3c/csswg-drafts/issues/7661 issue and noticed @tabatkins [saying](https://github.com/w3c/csswg-drafts/issues/7661#issuecomment-1569145287)

> Also, I think that in general everything people want to achieve with static positioning is achieved better, easier, and more reliably with anchor positioning. 

My issue here would be — I don't think an anchored element, currently, has an access to the grid of an element it would be positioned into? In order to utilize the grid with anchor positioning, right now we would need to have actual elements in the grid that we could then use as the target.

But what if we could target specific grid areas?

There are other cases where we could want to “specify” in more details what exactly we're targeting when selecting an anchor, for example, I agree that we would want an ability to target a particular fragment (https://github.com/w3c/csswg-drafts/issues/8895).

What if we could introduce a new function like `grid-area()` that could be used for this?

```CSS
anchor(--foo grid-area(content) center);
anchor(--bar grid-area(1 / span 2) start);
```

This way, for a particular anchor, we would first find the element that is associated with it, then would check if it is a grid, and if so, would try to find the area by the same syntax `grid-area` uses.

Alternative considered for a second: using the `grid-area` property itself when the anchor is active, but this won't really work as we could want to have multiple anchors with different grids.


Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8898 using your GitHub account


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

Received on Thursday, 1 June 2023 07:51:56 UTC