I got the impression that you can add a field for flex elements / children, and flexbox should automatically take this into account and calculate the correct distance between the elements.
I cannot make it work as I would like.
The fiddle is here: https://jsfiddle.net/dba5ehcw/1/
.flex-item{
border: 1px solid blue;
box-sizing: border-box;
height: 160px;
width: 50%;
}
Thus, each flex element is currently half the width of the container, and they fit well together.
I would like to be able to add a margin of, say, 1em to the flex elements to give them some breathing space, but at the same time they become more than 50% and no longer fit next to each other on the same line because they are too wide.
Is there a way to use a field on flex elements so that the flexbox container takes this into account and adjusts (decreases) their width accordingly?
source
share