1fr Is Not a Third of the Container
Published 12/2/2026 · 3 min read · Developer tools
Daniel Okonkwo — Front-end developer and tech writer at OneKitly
Web performance · File formats
Checked against 2 sources
The fr unit shares out the space that is left, not the space there is. A container 320 pixels wide with three columns and a 10-pixel gap loses 20 pixels to the two gaps, and the remaining 300 divide into three columns of exactly 100. Widen the gap to 24 and the columns drop to 90.67; add a fourth column at the original gap and they drop to 72.50. Any layout that assumes a column is the container divided by the column count will be wrong by exactly the gap total, which is why a design that fits at one breakpoint overflows at another.
Three 1fr columns in a 320-pixel container with a 10-pixel gap are 100 pixels each, not 106.67. The gaps are removed before the fractions are shared.
minmax is what stops a column collapsing
A bare 1fr has a minimum size of auto, which means the column will refuse to shrink below its content — a long unbroken word or a wide image will push the grid past its container and produce a horizontal scrollbar on a phone. Writing minmax(0, 1fr) sets the minimum to zero and lets the column shrink as intended, and it is the single most common fix for a grid that overflows on small screens. The generator emits plain 1fr because that is the readable default; the correction belongs wherever content can be wider than its cell.
repeat with auto-fit removes the breakpoints
Writing repeat(auto-fit, minmax(200px, 1fr)) tells the browser to fit as many 200-pixel columns as the container allows and to share the remainder among them. A 320-pixel phone gets one column, a 600-pixel tablet gets two, a 1000-pixel window gets four, and no media query is involved. That single line replaces most of what breakpoints used to be written for, and the number to choose is the narrowest a card can be before its content stops making sense.
| Columns and gap | Actual width | Naive division |
|---|---|---|
| 3 columns, 10 px | 100.00 px | 106.67 px |
| 3 columns, 24 px | 90.67 px | 106.67 px |
| 4 columns, 10 px | 72.50 px | 80.00 px |
| Gap total | columns − 1 gaps | the size of the error |
Frequently asked questions
- When is flexbox the better choice?
- When the layout is one line of items whose sizes come from their content — a toolbar, a row of tags, a navigation bar. Grid is for two dimensions and for a structure decided by the container rather than by the items; flexbox is for one dimension and for a structure that follows the content. Most pages use both, and the failure mode is using grid where the number of items is unknown or flexbox where columns must line up between rows.
- Do fractional pixel widths cause problems?
- Rarely, because browsers keep sub-pixel positions internally and only round when painting, so a column of 90.67 pixels lands where it should and the total still fits. What does show is a one-pixel difference in borders between adjacent cells at certain zoom levels, which is a rendering artefact rather than a layout error. If a design depends on exact pixel alignment, the fix is to control the gap and the container rather than to round the fractions.
Articles you may find interesting
All guides →Related tools
Sources
Spotted a mistake in this article?