Chrome does not expand flex parent according to children’s content [duplicate]

This appears to be a bug in Chrome.

In this section of code:

.items span {
  flex-basis: 25px;
  flex-shrink: 0;
}

… Chrome is not respecting the fixed 25px width. Or, at least, the container is not recognizing the space. It looks like the container is being sized before all item calculations are factored in.

The simple workaround is to use width instead of flex-basis.

.items span {
    flex-shrink: 0;
    width: 25px;
 }

revised demo


UPDATE

Bug Report

Flex-basis is being ignored when sizing nested flex containers.

“Yeah this is kind of a sucky consequence of a bug we have, perhaps combined with an unfortunate spec consequence…”

“When the outer flexbox finds the desired size of the inner flexbox, it asks for its max-content size (see LayoutFlexibleBox::computeInnerFlexBaseSizeForChild). But here’s where the bug comes in, the max-content size does not take flex-basis into account, only width properties/actual content. That’s why adding an explicit width fixes the bug.”

Leave a Comment