Skip to content
OneKitly

1fr Is Not a Third of the Container

Published 12/2/2026 · 3 min read · Developer tools

Daniel Okonkwo

Daniel Okonkwo — Front-end developer and tech writer at OneKitly

Web performance · File formats

Checked against 2 sources

View profile →
In short

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.

Advertisement

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.

Actual width
Column width in a 320-pixel container
Columns and gapActual widthNaive division
3 columns, 10 px100.00 px106.67 px
3 columns, 24 px90.67 px106.67 px
4 columns, 10 px72.50 px80.00 px
Gap totalcolumns − 1 gapsthe size of the error
CSS Grid GeneratorBuild a CSS grid layout visually — columns, rows, gaps and alignment — with a live preview and copyable CSS.Try the tool →
Advertisement

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 →
ExplainerContrast Ratio: How WCAG Actually Computes ItThe WCAG ratio is (L1 + 0.05) ÷ (L2 + 0.05), and L is relative luminance, not brightness. Green carries 71.52% of it and blue 7.22%, which is why pure blue on white passes at 8.59:1 while mid grey fails at 3.95:1. Here is the whole computation, run end to end.How-toHEX vs RGB: How to Read and Convert ColoursHEX and RGB are two notations for the same colours. Here's how to read each, convert between them, and add transparency.ExplainerGradients, Banding, and Why the Middle Looks MuddyInterpolating in sRGB averages gamma-encoded numbers, so the midpoint of red to green is #808000 when the half-light answer is #bcbc00 — 57.2% too little light. Banding is a separate arithmetic problem: 8 bits give 256 steps, and a dark gradient may have only 28 of them. Here is both, computed.ExplainerColour Schemes Are Geometry on a Wheel — and the Wheel Is WrongComplementary, triadic, analogous and split-complementary are just rotations: add 180°, 120°, 30° or 150° to a hue. The arithmetic is trivial. The problem is that the HSL hue circle is not perceptually uniform — yellow and blue at the same HSL lightness differ in luminance by 12.85 times — so a generated palette has to be contrast-checked afterwards.ExplainerNo Paper Size Matches the Shape Your Camera ProducesA 6000 by 4000 file at 300 dpi wants 50.8 by 33.87 cm, and nobody sells that. Filling an A4 costs 5.7% of the picture; filling a 40 by 50 costs 16.7%.ExplainerTwelve Megapixels Prints at 34 Centimetres, and That Is the Whole Story4000 × 3000 is 12 megapixels. At 300 dots per inch that is a print 33.9 cm wide. The count answers one question about a photograph and no others.

Related tools

Sources

Spotted a mistake in this article?