Skip to content

[css-grid] Shortcut syntax for repeat(M, 1fr) #2270

@LeaVerou

Description

@LeaVerou

I’ve noticed myself often defining grids where all I want is a bunch of equally sized rows, columns, or both. I.e. things like:

grid-template: repeat(M, 1fr) / repeat(N, 1fr);

or in one direction:

grid-template: 20em 1fr / repeat(N, 1fr);

Look at the first syntax. Isn't that a bit clunky, just to say that I want a M×N grid?
Wouldn’t it be much more elegant to be able to say:

grid-template: M / N;

And AFAIK <integer> has no meaning in grid-template right now, so the syntax is up for grabs and can be combined with other units as necessary, e.g.

grid-template-columns: 10em 4; /* equivalent to grid-template-columns: 10em repeat(4, 1fr);  */

Though admittedly, when combined with other units, its meaning is not as obvious as when used by itself.

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