THE GITHTML FIELD GUIDE

Fix a flex child that refuses to fit the reading column

A flex item can keep its automatic minimum size even when the container is narrow. Inspect the item's min-width or min-inline-size and its longest content before shrinking the whole page. Allow the relevant item to shrink, then handle any genuinely wide child with wrapping or local scrolling rather than clipping it.

Identify the specific failure

The oversized item may be several levels above the visible code block. Adding overflow to the code alone does not always fix an ancestor's minimum size. This explains why a seemingly reasonable responsive layout still pushes the entire document sideways.

Make a narrow correction

Apply min-inline-size: 0 to the flex item that should be allowed to shrink. Keep useful width constraints on actual content where needed. Do not hide page overflow as a first response, because that can conceal inaccessible text.

  1. Inspect flex-item ancestors of the element that appears too wide.
  2. Relax the relevant automatic minimum size rather than scaling the whole document.
  3. Give genuinely wide child content an explicit accessible overflow strategy.
css
.report-pane { min-inline-size: 0; }
.report-pane pre { overflow-x: auto; }

Trace the automatic minimum through nested flex items

Consider a row layout with a short navigation rail and a report pane containing a long unbroken identifier. The report pane is a flex item, and its automatic minimum can reflect the identifier's content size. The container may be narrow while the item refuses to shrink enough to fit. Inspect the direct flex item first, not just the identifier's own width. Applying min-inline-size: 0 to the intended reading pane allows the layout to allocate less inline space, after which the identifier still needs a deliberate wrapping or scrolling treatment.

Nested layouts can repeat the same constraint. A code block may sit inside a card that is itself inside a flex pane. If an outer item still imposes a large minimum, changing only the innermost block will not remove page-level overflow. Walk outward through the relevant containers and compare their measured widths. Adjust only the items that should actually be shrinkable; an unrelated icon or control may legitimately need a minimum size. Also confirm the layout axis and writing mode before assuming that a horizontal-width correction addresses a vertically constrained component.

Do not replace the diagnosis with overflow: hidden on the entire page. That can make the scrollbar disappear while leaving part of the identifier, table, or link unreachable. A successful result has two properties: surrounding prose fits the viewport, and any content that genuinely needs more space remains accessible in its own region. Test both a long token and a wide table because they may need different treatments. Repeat after the navigation rail becomes longer or wraps, since the available space for the report pane can change even when its own text stays the same.

Verify the repaired artifact

Test the longest identifier and the widest table after the change. The surrounding prose should fit while necessary wide content remains reachable.

Sources and further reading

AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.

All html troubleshooting guides →

Read as MarkdownAll guides

Fix a flex child that refuses to fit the reading column · gitHtml