Skip to content

[css-grid-1] Unpredicable gap positioning with two or more tracks. #7197

Closed
@Tenkir

Description

@Tenkir

When defining a grid layout with multiple tracks of fractional units, the alignment of the grid-gap property with relation to the overall grid does not align to the expected behavior of the specification.

Take for example, a grid layout of

grid-template-columns: 50fr 50fr;
grid-gap: 10px;

This layout will split each column evenly, resulting in a 5px gap on the left most column, and a 5px gap on the right most column.

Screen Shot 2022-04-04 at 10 14 13 PM


However, expand this with a third column as such:

grid-template-columns: 50fr 25fr 25fr;
grid-gap: 10px;

This layout will split the two 25fr columns evenly, as expected. However, the gap between the 50fr column, and the 25fr column will not be even. Rather, the entirety of the gap will be on the 50fr side of the split.

Screen Shot 2022-04-04 at 10 19 27 PM


This is a significant issues with more complex layouts, as the gap between children becomes unpredictable, and alignment of any meta-elements becomes impossible.

Screen Shot 2022-04-04 at 10 20 10 PM

Spec:
https://www.w3.org/TR/css-grid-1/

Minimum Reproduction:
https://codesandbox.io/s/wild-leftpad-h2f782?file=/index.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closed as Question AnsweredUsed when the issue is more of a question than a problem, and it's been answered.css-grid-1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions