Entry 02
Intrinsic grid
Use it for any set of equal cards or tiles. It replaces a column count per breakpoint.
Code
.grid {
display: grid;
gap: 1rem;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
}Why it works, the rules and the credits
Why it works
auto-fitcreates as many 16rem columns as the row holds, and1frshares what is left. The column count follows the container.min(100%, 16rem)lets the minimum shrink to the container. Without it a 200px container overflows.
Rules
auto-fitstretches a short row to fill the width. Useauto-fillwhen the item count changes, such as a filtered list, so cards keep their size.
Support
- Chrome
- 79
- Firefox
- 76
- Safari
- 11.1
Credits
Borrowed from: Kevin Powell, Breakpoint-Free CSS Grid Layouts, 2025-02-19 · Stephanie Eckles, Smol Responsive CSS Grid · Una Kravets, Ten modern layouts in one line of CSS