Please tell me how the Flex layout automatically adapts the box size to child elements that exceed the width of the screen.

the example is here: https://codepen.io/mashirozx/...

page uses column wrap layout, want to constantly load new content, and in the form of child elements append into the box, beyond the width of the screen can scroll (overflow-x), so the width of the box can be automatically adjusted according to the width of the child elements, similar to the traditional layout of width: auto .

this is the current situation:

:

how should I adjust it?

Jun.09,2022

add overflow: auto;


to the flex box

if you need to keep the outer margin of the 10px at the end (rightmost), you can add:

to the answer upstairs.
.flex-container-content > div:last-child {
  border-right: 10px solid -sharp333;
}

the calculation of the width of the parent container is extremely complex here, and the conclusion is that according to the visual formatting model, the right margin will be ignored. If you are interested, please take a look at the standard explanation: https://www.w3.org/TR/CSS22/visudet.html-sharpblockwidth


both of you upstairs are done, that's what happened

Menu