THE GITHTML FIELD GUIDE
Why a one-fr grid column can overflow its container
A grid track declared as 1fr can still be constrained by content's automatic minimum size. For a reading pane that must shrink, consider minmax(0, 1fr) and inspect the grid item's own minimum sizing. Keep wide evidence scrollable within the pane rather than hiding overflow at the page level.
Identify the specific failure
A long unbroken value can contribute a large minimum size to a grid track. The remaining flexible space is then not the only factor determining the track width. This can surprise authors who expect 1fr to mean never wider than the available screen.
Make a narrow correction
Change the intended flexible track, not every grid in the document. Check nested grids and the relevant item's min-inline-size. A zero minimum permits shrinking but does not automatically wrap an image, table, or identifier inside the track.
- Inspect the track definition and the minimum size of its direct grid item.
- Use an explicit zero minimum where the reading pane should be shrinkable.
- Handle wide descendants independently and avoid masking them with overflow: hidden.
.layout { display: grid; grid-template-columns: minmax(0, 1fr); }Separate track sizing from the content inside the track
Imagine a grid with a fixed-width index and a flexible report column. The report column is declared as 1fr, but a long code sample pushes the complete grid beyond the viewport. Flexible distribution does not mean that the track's minimum contribution is zero. Compare that definition with minmax(0, 1fr) for the report track, then inspect whether the grid item itself still has a restrictive minimum. Treat the track and its item as separate places where a minimum-size assumption can enter the layout.
Once the track can shrink, the code sample may overflow inside it. That is progress in isolating the issue, not the finished correction. Give the sample local scrolling or suitable wrapping according to its meaning. An image may instead need a maximum inline size and proportional height. Do not apply the same clipping rule to every descendant, because a table that needs horizontal comparison and prose that should wrap have different reading requirements. Test the actual descendant that originally forced the large size rather than using only a short replacement paragraph.
For a small-screen reading layout, also question whether the index should remain a side column at all. Moving navigation above the report can be clearer than squeezing two columns into a narrow width. Use that as an intentional layout choice, not as a substitute for understanding the minimum-sizing problem. Check the transition where the layout changes and include the longest index label. The corrected design should retain a coherent source order and complete content whether it uses one column or two, without requiring the reader to pan the whole document sideways to follow ordinary sentences.
Verify the repaired artifact
Compare a short paragraph and a deliberately long code sample. Both should remain usable without moving the outer page sideways.
Sources and further reading
AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.