Open xiaochengh opened 1 year ago
This would be really nice to have! Especially if we could expand it to support something like nth or nth-last, to select a particular fragment by its index.
Could be very helpful for things like wrapped inline elements, multicol, wrapped flex elements, and maybe grids (though, thinking of grids, I did create a separate issue, as with them we could probably utilize the existent grid-area syntax in order to select the existing areas).
Agenda+ to ask if we should add this functionality in some form (and then we can follow up with specifics).
Another case this would be very useful for is paged media. Addressing fragments would likely be much easier for document authors to understand and use than the bounding boxes of all fragments. (We are not even sure ourselves what the bounding box of fragments spread over multiple pages should be, especially when these pages vary in size. But that feels like it's own issue.)
The CSS Working Group just discussed [css-anchor-1] Allow anchoring to a particular fragment
, and agreed to the following:
RESOLVED: add margin-box and border-box keywords
RESOLVED: add properties position-anchor-name and position-anchor-box as longhands of position-anchor
When an element is fragmented across lines/columns, the current spec says we can only anchor to the axis-aligned bounding box of its fragments. But sometimes we want to anchor to the first/last fragment instead.
For some real world use cases, if we have selected a few lines of text:
Floating UI supports this: https://floating-ui.com/docs/inline
How about adding an additional parameter to
anchor()
andanchor-size()
to specify which fragment to anchor to? For example:And the default value is
bounding-box