Note there is a similar question here, however the pure css answer uses flex-direction: column
for the container.
It seems the answer to the original question is that flexbox does not support this, however I'm also wondering whether it's possible with CSS Grid. Perhaps better asked in a new question...
I have a flexbox container with a few hundred items in them containing variable length text and white-space
is set to nowrap
to ensure that the text does not wrap. Here's an example:
<div style="display:flex; flex-direction: row;">
<div>Short label</div>
<div>Really really really looooooong label</div>
<div>Really really really looooooong label that's even longer</div>
...
<div>And so on for a few hundred of these divs</div>
</div>
Is there a set of flexbox parameters that will cause all the items to have a width that is equal to the width of the items with the longest content? In this case that would be the div
:
<div>Really really really looooooong label that's even longer</div>
What I could do is measure the length of the above div and set the minimum width to that length, but I'm wondering if flexbox has a way of doing this automatically? Currently, as @M0ns1f is pointing out in his answer, it seems the only way to do this is to set minimum-width
either manually or via javascript.