liveBook · Manning

Auto-fill

As explained in CSS in Depth, Second Edition

The CSS auto-fill keyword makes a repeat() track definition create as many tracks as fit within the available space and specified size constraints.

In CSS Grid, auto-fill tells repeat() to create as many tracks as fit the available space while respecting the supplied size constraints. Combined with minmax(200px, 1fr), it keeps columns at least 200px wide and adds fewer or more columns as the viewport changes. section 5.4

Responsive portfolio grid

Use grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));. A viewport wide enough for four 200px columns gets four tracks; a narrower viewport gets fewer. Wider space can create more. auto-fill may also leave empty tracks when too few grid items exist. section 5.4

How CSS in Depth, Second Edition covers it

How deep it goes
Explains repeat(), minmax(), track limits, viewport changes, and empty tracks through a concrete portfolio grid.
Examples
Uses a photographic portfolio, four-column viewport example, and a complete repeat(auto-fill, minmax()) declaration.
What it assumes
Assumes basic grid tracks and repeat(), while explaining minmax() and auto-fill in context.
What you can do after
Apply it via CSS Grid to create responsive columns constrained by minimum and maximum track sizes.
How it connects
Connects auto-fill with CSS Grid, repeat(), minmax(), implicit grid rows, and responsive layout.

Also explained in

Compare how 2 books explain auto-fill →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of CSS in Depth, Second Edition. The section links point to the parts of the book it draws on.