Can’t really do that, because buttons labels might be both short and very long, so it should just shrink, but it doesn’t in columns if column holders is flex row (shrinks if that row is block)
It’s not clear to me what you want the layout to look like in your examples. What should the Button 5, 6, 8, and 9 areas look like?
Also it might be useful to understand what this complex layout is trying to serve – what does the UI you’re trying to create look like?
Flexbox is not Grid, and there are things one or the other is better at. That said, many complex layouts at Adobe and in 3P plugins have been accomplished with Flex and the existing layout models, but it may take some additional work when compared to Grid. This is why I’m asking for your desired UI layout – sometimes you may need to invoke more than just flexbox to get what you’re after.
So in the first image, if I try to shrink viewport right past that width, Button 5 and 6 rows drop down bellow instead of wrapping buttons (like they do in second screenshot when row takes full viewport width). I’d want buttons to wrap if they can’t fit in a single row the same as what happens when row is in full viewport width.
For the second image, Button 1/2/3/4/8 columns do not allow buttons to shrink like rows (5, 6, 9) do. Buttons labels should be truncated with ellipsis, like in rows, but instead they stay the same smallest size.
I’m fine with adding some other solutions, but I need this to be responsive as much as possible with as less HTML as possible. I don’t see how media queries would help here, because buttons can have any length labels and rows/columns can have any number of buttons, which I don’t know…
OMG, it does solve Thank you so much for such a simple solution
Why would column (in a row specifically) have some default min-width? Never would’ve figured this out by myself
An initial setting on flex items is min-width: auto . This means that a flex item, by default, cannot be smaller than the size of its content.
Therefore, text-overflow: ellipsis cannot work because a flex item will simply expand, rather than permit an overflow. (Scroll bars will not render either, for the same reason.)
To override this behavior, use min-width: 0 or overflow: hidden
I probably googled “flex child overflowing parent width” 10 times in my life already, because I always forget about this fix
Regarding your first problem:
I don’t think either that there’s a solution for that, other than controlling the wrapping with media queries.
If I understand the problem correctly, you have two wrapping elements which are “in competition” with each other. While resizing the viewport, the browser calculates the necessary space and checks it against the available space. Once there isn’t enough space, it has to decide whether it will wrap the outer container or the contents of the inner row.
Unfortunately, there’s no way to set wrapping priority, so you can’t control the order in which elements wrap.
I found this example, which seems to show the opposite behavior of what your code does (inside wraps before outside). This makes me assume that wrapping simply happens in chronological order.