Flexbox: wrong width calculation when flex-direction: column, flex-wrap: wrap

This appears to be yet another bug in the Flexible Box Layout Module involving flex-direction: column and flex-wrap: wrap.

Browsers seem to be all over the place on this issue.

In this particular case, as stated in a bug report:

It seems to me that the width is calculated as if the inside elements were laid out horizontally (flex-direction: row) instead of vertically.

In other cases, the opposite occurs:

In both cases, there are currently no flex methods to resolve the problem.

For this particular question, one developer offers a CSS workaround, but I’m not sure it works in all browsers. I wouldn’t recommend it unless you’re truly desperate:

In some instances, you may be able to workaround this issue by using
vertical writing mode.

That is, instead of using flex-direction: column;, use
flex-direction: row; writing-mode: vertical-lr;. Remember to reset
to writing-mode: initial; in the children of the flexbox.

https://bugs.chromium.org/p/chromium/issues/detail?id=507397

Bug reports:

Leave a Comment