Why Flex Items Refuse to Shrink: `min-width: auto`
A flex item keeps a content-based automatic minimum size and forces a row wider than a narrow viewport even when shrinking is enabled.
min-width: auto- Viewport / page
- --
- Flex item
- --
- Page overflow
- --
min-width: 0- Viewport / page
- --
- Flex item
- --
- 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 text column keeps a content-sized floor
The filename has no convenient wrapping point. The middle flex item keeps its automatic minimum inline size, so its code block contributes a width larger than the available row.
Minimal code diff
Allow the flex item to shrink
Set the flexible item minimum inline size to zero and keep unavoidable scrolling local to the code region.
Before
.build-copy {
flex: 1 1 auto;
}After
.build-copy {
flex: 1 1 auto;
min-width: 0;
}
.build-copy pre {
max-width: 100%;
overflow-x: auto;
}Root cause
A flex item has an automatic minimum size by default. Depending on its overflow and content, that minimum can be based on the min-content width. The item can therefore refuse to become narrower than a long unbroken descendant.
Setting min-width: 0 on the flexible item permits it to shrink below that content-based floor. This does not decide how every child should render, so a wide code or data region still needs an intentional local overflow or wrapping policy.
Diagnose the flex item, not only its child
Measure the flex container, each direct flex item, and the long descendant separately. The failing signal in this fixture is a flexible item whose rendered width stays near its min-content contribution even though the row has less available space. A temporary min-inline-size: 0 on that direct item should reduce the page width immediately; applying the same declaration only to the nested pre does not change the flex item’s automatic floor.
After the item shrinks, verify that the child still has a deliberate behavior. Ordinary prose should reflow, while the exact filename in this case remains available through the labeled local code region. This second check prevents a visually narrow layout from passing by clipping the content that originally exposed the sizing problem.
When this fix is not enough
Apply the rule to the flex item that needs to shrink, not indiscriminately to every descendant. If the page is still wide, measure all ancestor and child bounds; fixed-width media, transforms, negative margins, and nested grid tracks are separate mechanisms.
Regression condition
The failing fixture should overflow at the narrow test viewports. The fixed fixture must keep the page width stable while the long filename remains reachable inside its local scroll container.
Primary references
Sources checked for this case
- CSS Flexible Box Layout Module Level 1 - automatic minimum size - 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 | +144 / +0 | +89 / +0 | +0 / +0 | +0 / +0 | +0 / +0 |
| Firefox | +145 / +0 | +90 / +0 | +0 / +0 | +0 / +0 | +0 / +0 |
| WebKit | +172 / +0 | +117 / +0 | +0 / +0 | +0 / +0 | +0 / +0 |
18/18 recorded assertions passed
chromium-failing-overflow-320144pxchromium-fixed-overflow-3200pxchromium-fixed-local-scroll-320184pxchromium-failing-overflow-37589pxchromium-fixed-overflow-3750pxchromium-fixed-local-scroll-375129pxfirefox-failing-overflow-320145pxfirefox-fixed-overflow-3200pxfirefox-fixed-local-scroll-320185pxfirefox-failing-overflow-37590pxfirefox-fixed-overflow-3750pxfirefox-fixed-local-scroll-375130pxwebkit-failing-overflow-320172pxwebkit-fixed-overflow-3200pxwebkit-fixed-local-scroll-320212pxwebkit-failing-overflow-375117pxwebkit-fixed-overflow-3750pxwebkit-fixed-local-scroll-375157px
Run 2026-08-04T11-36-57-234Z. chromium 149.0.7827.201, firefox 153.0, webkit 26.5. Open raw manifest