Skip to content

[css-grid-3][masonry] Negative margins should affect gaps between items #13574

@celestepan

Description

@celestepan

I'd like to propose a change to the spec where negative margins "eat" into the grid-gap placed between items.

The spec states that negative margins should affect the contribution of an item to the running position down to 0px (https://www.w3.org/TR/css-grid-3/#grid-lanes-layout-algorithm), but specifies that the stacking axis gap should be added to the running position of a track after an item is placed.

The running position contribution of an item in the spec right now is:
max_pos + clampToZero([outer size](https://www.w3.org/TR/css-sizing-3/#outer-size)) + [grid-gap](https://www.w3.org/TR/css-align-3/#propdef-grid-gap).

I think the formula should be changed to:
max_pos + clampToZero(outer_size + grid-gap)

If an item 1 has height: 30px, margin-top: -40px and the gap is 10px, following the spec formula, we'd get:
Image

Whereas if we don't always add the stacking axis gap afterwards, we would end up with:
Image
which doesn't have that awkward gap at the top of track 1.

If we were to follow the spec, a user could also continuously place items with a negative margin greater than its size, and the grid-gap would just continuously add to the running position of that track.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions