auto-fit
A repeat() keyword that creates as many tracks as fit the container, then collapses empty ones so the filled tracks stretch to use the space.
In more detail
With few items, auto-fit makes them grow to fill the row. The number of columns is roughly the container width plus one gap, divided by the minimum track size plus one gap, rounded down.
Related terms
- auto-fill — A repeat() keyword that creates as many tracks as fit the container and keeps the empty ones, leaving blank columns if there are few items.
- repeat() — A CSS Grid function that writes a track pattern many times, such as repeat(3, 1fr), or as many times as fit with auto-fit or auto-fill.
- minmax() — A CSS Grid function that lets a track size vary between a minimum and a maximum, such as minmax(280px, 1fr).
Taught in
- Advanced CSS Grid: Named Areas, minmax And auto-fit — Frontend Architecture & Web Platform