Skip to content

[css2][css-position] Static position needs to ignore floats #9991

Open
@Loirooriol

Description

@Loirooriol

https://drafts.csswg.org/css2/#abs-non-replaced-width

The static position for left is the distance from the left edge of the containing block to the left margin edge of a hypothetical box that would have been the first box of the element if its position property had been static and float had been none.

https://drafts.csswg.org/css-position/#staticpos-rect mostly defers to CSS2, but adding clear: none:

Finding the static position and the static-position rectangle assumes that both float and clear (as well as position) have their initial values

But assuming clear: none is not enough, this needs to entirely disregard floats, see this testcase:

<!DOCTYPE html>
<div style="overflow: hidden; position: relative; width: 100px; border: solid; margin: 1em 0">
  <div style="float: left; width: 50px; height: 50px; background: magenta"></div>
  <div style="position: absolute; overflow: hidden; width: 25px; height: 25px; background: cyan"></div>
</div>
<div style="overflow: hidden; position: relative; width: 100px; border: solid; margin: 1em 0">
  <div style="float: left; width: 50px; height: 50px; background: magenta"></div>
  <div style="position: static; overflow: hidden; width: 25px; height: 25px; background: cyan"></div>
</div>

Gecko, Blink and WebKit agree:

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