Skip to content

[css-grid] Clarify how collapsed tracks affect positions of abspos elements in the presence of gaps #10813

Open
@Loirooriol

Description

@Loirooriol

We only collapse tracks when they are empty, so this is usually not a problem.

However, being empty only refers to grid items, so an empty track can still have abspos elements.

<!DOCTYPE html>
<style>
.grid { position: relative; display: inline-grid; grid-template: 100px 100px / 100px repeat(auto-fit, 0) 100px; grid-gap: 10px }
.grid > div { position: absolute; inset: 0; min-width: 1px; display: flex; flex-wrap: wrap; place-content: center }
</style>
<div class="grid">
  <div style="grid-row: 1 / 2; grid-column: 1 / 2; background: cyan">1</div>
  <div style="grid-row: 2 / 3; grid-column: 1 / 3; background: magenta">2</div>
  <div style="grid-row: 1 / 2; grid-column: 3 / 4; background: orange">3</div>
  <div style="grid-row: 2 / 3; grid-column: 2 / 4; background: lime">4</div>
  <div style="grid-row: 1 / 3; grid-column: 2 / 3; background: black">5</div>
</div>
Firefox Chrome/WebKit

Both Firefox and Chrome/WebKit agree that:

  • Even though it spans an extra column at the end, item 2 should end at the same position as item 1.
  • Even though it spans an extra column at the start, item 4 should start at the same position as item 3.

They disagree with the position of item 5, though:

  • Firefox puts it touching to item 2, which is consistent with them having the same grid-column-end, but that differs from item 4 even though they have the same grid-column-start.
  • Chrome/WebKit put it touching to item 4, which is consistent with them having the same grid-column-start, but that differs from item 2 even though they have the same grid-column-end.

The spec just says that the track should be treated as having a fixed track sizing function of 0px, which would result in

and also

When a collapsed track’s gutters collapse, they coincide exactly—​the two gutters overlap so that their start and end edges coincide.

which isn't clear about what happens with the start and end positions of the track.

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