`1fr` vs `minmax(0, 1fr)`: Prevent Grid Overflow
A flexible grid track keeps an automatic minimum based on long content and expands beyond the available inline size.
grid: 88px 1fr- Viewport / page
- --
- Grid track
- --
- Page overflow
- --
grid: 88px minmax(0, 1fr)- Viewport / page
- --
- Grid track
- --
- Page overflow
- --
Three-browser evidence verified. Live values come from your current browser. The formal matrix records the controlled browser runs and fixture revision used for the published conclusion.
Observed failure
The `1fr` track keeps its automatic minimum
The second track is flexible, but its minimum is still automatic. A long unbroken command gives the track a min-content floor larger than the remaining space.
Minimal code diff
Give the flexible track a zero minimum
Use `minmax(0, 1fr)` for the track that may shrink, then define local overflow behavior for its wide child.
Before
.result-grid {
grid-template-columns: 88px 1fr;
}After
.result-grid {
grid-template-columns: 88px minmax(0, 1fr);
}
.result-output {
min-width: 0;
overflow-x: auto;
}Root cause
An fr unit distributes leftover space, but a track written as 1fr still has an automatic minimum. When a grid item contains a long unbroken value, that content can establish a minimum wider than the free space. The track then grows and the document overflows.
minmax(0, 1fr) makes the intended lower bound explicit. The track can become smaller than its min-content contribution while continuing to receive the remaining space.
Confirm which track establishes the floor
Use the browser’s grid inspector and compare the grid’s content width with the long item’s scroll width. In the controlled fixture, the fixed first track is stable and the nominally flexible second track expands. Replacing only that second track with minmax(0, 1fr) makes the grid fit immediately, which distinguishes the track-sizing cause from padding, viewport units, or an unrelated fixed-width ancestor.
The item inside the track still needs its own content decision. The fixture gives its command output a local scroll area because preserving the exact string matters. A translated label or normal paragraph would use wrapping instead. Testing both the grid boundary and the descendant’s reachability prevents a zero minimum from becoming an accidental clipping technique.
When this fix is not enough
The wide descendant still needs an intentional behavior. Code and data may use a reachable local scrollbar, while ordinary prose may need wrapping. A zero track minimum should not be used to hide clipped controls or inaccessible content.
Regression condition
At narrow viewports, the failing grid should produce page-level overflow. The fixed grid must remain within the page, and its long command must remain accessible through the local output region.
Primary references
Sources checked for this case
- CSS Grid Layout Module Level 2 - flexible lengths - W3C, checked 2026-08-04
Formal evidence
Browser and viewport matrix
Cells show failing / fixed page overflow in CSS pixels.
| Browser | 320 | 375 | 768 | 1024 | 1440 |
|---|---|---|---|---|---|
| Chromium | +164 / +0 | +109 / +0 | +0 / +0 | +0 / +0 | +0 / +0 |
| Firefox | +164 / +0 | +109 / +0 | +0 / +0 | +0 / +0 | +0 / +0 |
| WebKit | +195 / +0 | +140 / +0 | +0 / +0 | +0 / +0 | +0 / +0 |
18/18 recorded assertions passed
chromium-failing-overflow-320164pxchromium-fixed-overflow-3200pxchromium-fixed-local-scroll-320204pxchromium-failing-overflow-375109pxchromium-fixed-overflow-3750pxchromium-fixed-local-scroll-375149pxfirefox-failing-overflow-320164pxfirefox-fixed-overflow-3200pxfirefox-fixed-local-scroll-320204pxfirefox-failing-overflow-375109pxfirefox-fixed-overflow-3750pxfirefox-fixed-local-scroll-375149pxwebkit-failing-overflow-320195pxwebkit-fixed-overflow-3200pxwebkit-fixed-local-scroll-320235pxwebkit-failing-overflow-375140pxwebkit-fixed-overflow-3750pxwebkit-fixed-local-scroll-375180px
Run 2026-08-04T11-36-57-234Z. chromium 149.0.7827.201, firefox 153.0, webkit 26.5. Open raw manifest