Skip to content

[css-position] Insets don't reduce the cb when sizing an abspos #5082

@Loirooriol

Description

@Loirooriol

From https://drafts.csswg.org/css-position/#abspos-insets

For an absolutely positioned box, the inset properties effectively reduce the containing block into which it is sized and positioned by the specified amounts.

And https://drafts.csswg.org/css-position/#abspos-layout goes on with

  1. First, its inset-modified containing block is calculated, defining its available space. (See § 3.5 Absolute (and Fixed) Positioning.) [...]
  2. Next, its width and height are resolved against this definite available space [...]

But that's not actually the case. Percentages are resolved with respect to the original containing block size, not the inset-modified one. E.g.

#cb {
  position: relative;
  width: 100px;
}
#abspos {
  position: absolute;
  left: 25px;
  right: 25px;
  width: 100%;
  height: 100px;
  background: blue;
}
<div id="cb">
  <div id="abspos"></div>
</div>

results in a 100x100 square, not a 50x100 rectangle. https://software.hixie.ch/utilities/js/live-dom-viewer/saved/8114

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions