Positioning: the containing block, the top layer, anchors
Anchor positioning is changing; verify each of these against the build in front of you.
1. What a positioned box resolves against
An absolutely positioned box resolves against the padding edge of its nearest ancestor whose
positionis notstatic, and against the initial containing block (the viewport-sized rectangle at the canvas origin) when there is none. Percentages ininset,width,heightandmax-heightresolve against that box, not against the parent element.A
transformor an individualtranslate,rotateorscale,transform-style: preserve-3d,offset-path,filter,backdrop-filter,perspective,contain: layoutorpaint(and sostrict,contentandcontent-visibility: autoorhidden), or awill-changenaming one of them, makes the ancestor the containing block for absolute and fixed descendants alike. A fixed descendant of a transformed toolbar or panel positions and scrolls with that ancestor, not the viewport, while its computedpositionstill readsfixed.container-typedoes not do this, so a size container leaves a fixed descendant on the viewport. Before explaining a misplaced fixed box, walk its ancestors for these properties.position: fixedtakes the box out of the page’s scrollable overflow and resolves its percentages against the viewport, but the element can no longer be scrolled into view. Clamping to the viewport can leave nothing visible where the thing the box belongs to is off-screen.
2. The top layer
A top-layer element with
position: absoluteresolves against the initial containing block and contributes to the document’s scrollable overflow. The UA sheet makes[popover]and a modaldialogposition: fixed, which stays out of it (§1), but an anchored popover usually overrides that withabsolute, so the popover can grow the page and add a scrollbar.Decorative boxes count; ink does not. An absolutely positioned background at a negative inset contributes scrollable overflow, so it can grow the page on its own.
box-shadowandoutlinedo not. A box pushed past its ancestor’s border box by a negative margin or inset contributes scrollable overflow the same way.The UA sheet gives a popover
overflow: auto, so it clips decoration that reaches outside it. SKILL.md §3 “Keep the line box and the ink apart” has the mechanism.
3. Anchor positioning
max-height: 100%on an anchored element is not “the viewport”. Withposition-area, percentages resolve against the position-area region, which for a box in a scroll container spans the container’s scrollable overflow, so on a page that already scrolls the clamp can reach past the viewport; aposition: fixedbox’s region stays inside the viewport. Measure what100%resolved to before relying on it.Anchor positioning compensates for scroll with a translation, not a re-layout. Scrolling slides the box but never gives it more room, until its placement stops fitting; then scrolling triggers a reflow that tries
position-try-fallbacksagain.position-try-fallbacksfires when the box’s size exceeds the position area, which amax-heightclamp prevents. Overflow frommin-heightbeating the clamp does count; content spilling out of a fixed-size box does not. A scrollable containing block makes an option reaching far outside the viewport count as fitting, since the area follows its scrollable overflow (above). The test compares sizes only, so where an option lands the box does not reject it. The property can be supported, applied and present on the computed style while never engaging, so check the computedposition-arearather than the fallback property.An absolutely positioned box that overflows its position area slides back inside the original containing block once every fallback has failed. Whether its size is auto or explicit, a box larger than its position area but no larger than the containing block on both axes is shifted to fit the containing block, so a box placed below or beside its anchor can end up covering the anchor; a box larger than the containing block on either axis is shifted on neither, start-aligns and overflows. A box no larger than its area never slides, so a reduction with a small fixed size fails to reproduce, and capping the box at the area (
100%resolves against it) underbox-sizing: border-boxkeeps it in place. Noalign-selfvalue opts out in Gecko, not even theunsafeforms (bug 2072587).position-area’sspan-*values include the anchor’s own row or column.span-block-endruns from the anchor’s block-start edge to the container’s block end, so a box meant to sit below the anchor and not over it wants plainblock-end.An anchor must be laid out before the box anchored to it. For a top-layer element that compares top-layer order; otherwise the anchor must sit inside the positioned element’s containing block (§1), or that containing block must be the initial containing block. A top-layer popover can anchor to an element in the page, but an absolutely positioned child of that popover cannot: its containing block is the popover, and the anchor is not inside it.
inline-size: stretchis behindlayout.css.stretch-size-keyword.enabled, off by default, soCSS.supportsreturns false on a normal build;-moz-availableworks. To fill a position area minus the box’s own margins,inset-inline: 0withjustify-self: stretchworks and is unprefixed.@position-tryaccepts only insets, margins, sizing, self-alignment,position-anchorandposition-area.