Skip to content

[css-position-3] Absolute positioning - Is the new inset & auto-size behaviour web-compatible? #11195

Open
@dshin-moz

Description

@dshin-moz

Implementing justify-self & align-self for abs-positioned elements, we ran into:

Which has something to the effect of:

<!DOCTYPE html>
<style>
.abs {
  position: absolute;
  align-self: stretch;
  height: auto;
  top: auto;
  bottom: auto;
  background: lime;
}
</style>
<div class="abs">Test</div>

align-self: stretch should be a no-op (At least for absolute elements not within flex/grid context) in the old behaviour, but seems to be used by websites in the wild anyway in the linked bugs:

  • Virustotal: <uno-navbar>'s shadow-root child
  • SAP: opblock-summary-method

As per the new absolute-positioning steps:

  1. Calculate inset-modified containing block:
  2. Resolving sizes: Definite available size is viewport, no min/max height is given, and since self-alignment is stretch, auto size is stretch size.
  3. Auto margins: N/A
  4. Alignment: Fits exactly in the available space

As per the old steps

  1. Everything is auto, margins zeroed out, top takes its static position value, which is zero
  2. Height is Auto heights for block formatting context roots - Distance between top of the topmost line box and bottom of the bottommost line box, so auto size is basically a shrink-fit size.
  3. Solve for bottom, taking up whatever empty space

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Regular agenda items

    Status

    Regular agenda

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions