repeat()

The repeat() function compactly defines repeated grid tracks.

Since CSS3 Spec ↗

Syntax

repeat(<count|auto-fill|auto-fit>, <track>...)

Examples

.fixed { grid-template-columns: repeat(4, 1fr); }
.fluid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
Output
The first grid has four equal columns; the second fits as many 200px+ columns as space allows and stretches them.

Notes

Use an integer for a fixed count. auto-fill keeps empty implicit tracks; auto-fit collapses empty tracks so existing items stretch to fill. Only valid in grid track lists.

Browser & runtime support

EnvironmentSince version
chrome 57
firefox 52
safari 10.1
edge 16

See also