-
Notifications
You must be signed in to change notification settings - Fork 765
Description
(Split off from #8979 (comment))
The current spec of anchor-center tries to fit the element within the inset-modified containing block without triggering position fallback.
This doesn't work if the anchor is initially outside the containing block and can be scrolled back. In this case, the inset-modified containing block (regardless of how you computed it, via the current spec text, or current resolution of #9124, or @fantasai's alternative proposal there) is collapsed, and the element ends up not center-aligned with the anchor, but instead:
- Start-aligned with the anchor per the current spec text or @fantasai's proposal
- Start-aligned with the containing block per current resolution of [css-align-3][css-position-3] Better interaction of auto insets and self-alignment properties? #9124
My proposal
If there's anchor-center alignment on an axis, then:
- Always center-align the element with the anchor without considering insets
- If the result of 1 overflows the scroll-adjusted IMCB and there are fallback positions, trigger position fallback
- The scroll-adjusted IMCB should be computed following the current resolution of [css-align-3][css-position-3] Better interaction of auto insets and self-alignment properties? #9124, namely, treating any
autoas0
- The scroll-adjusted IMCB should be computed following the current resolution of [css-align-3][css-position-3] Better interaction of auto insets and self-alignment properties? #9124, namely, treating any
Discussions
I think the highest priorities are:
- Scrolling doesn't trigger relayout, except when fallback position is changed
- We should get the same layout for (i) anchors initially in the CB, and (ii) anchors that can be scrolled into CB
And I don't see any way to achieve these two at the same time if we also want to support "fitting the element within the IMCB by shifting it around", which the current spec wants to support.
This proposal also requires the current resolution of #9124. The rationale is straightforward: suppose we are positioning a popover (with position: fixed), and want it to be center-aligned with an anchor, and trigger position fallback when reaching the viewport boundaries. Then the IMCB is simply the viewport, which is inset: 0.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status