-
Notifications
You must be signed in to change notification settings - Fork 756
Description
I did recently stumbled upon some weirdness regarding how flex and overflow interact.
I could not find an issue that would talk about it, and couldn't find the exact place in the specs that describe this interaction, so would be helpful for any directions!
Disclaimer: this might be also the case for display: grid, I did not thoroughly tested anything other than display: flex for now.
References:
- A codepen with my examples: https://codepen.io/kizu/pen/oNaxbjo
- The only issue that I found that is kinda related — [css-sizing][css-grid][css-flexbox] Intrinsic Sizes, Scroll Containers, and Grid/Flex Sizing #1865
- CSS Box Sizing Module Level 3 — https://www.w3.org/TR/css-sizing-3/
- CSS Overflow Module Level 3 — https://www.w3.org/TR/css-overflow-3/
- CSS Flexible Box Layout Module Level 1 — https://www.w3.org/TR/css-flexbox-1/
The problem:
-
When we have a container that has both
display: flexand a non-visibleoverflow(my exact case was withoverflow: auto), we do not have any control on how the inner content box of the overflowing container is sized, resulting in content always shrinking up to the items' respective min intrinsic sizes:Screen.Recording.2023-04-14.at.21.19.44.mov
-
What I want to have, achivable, for example, if we would instead move the flex container inside the container with the
overflow— we get control over how it would behave viamin-widthorheight: the container is sized to fit all the items:Screen.Recording.2023-04-14.at.21.20.18.mov
My proposal:
- Add a CSS property (or multiple?) that would control how the content area of the overflowing container should be sized.
Current workarounds:
- The already mentioned separation of the overflow and flex — allows achieving both cases: when we want things to shrink, or not.
- Using
.flex > * { flex-shrink: 0; }— kinda works, but only for thestartvalue of thejustify-contentproperty, otherwise things behave not in a desired way.