It seems that Chrome doesn\'t handle justify-content: space-around
correctly when the content overflows the flex container, and the container is not set up to a
That's because when there isn't enough space, space-around behaves like center
:
If the leftover free-space is negative or there is only a single flex item on the line, this value is identical to center.
And center behaves like you describe:
If the leftover free-space is negative, the flex items will overflow equally in both directions.
Instead, you can use space-between:
If the leftover free-space is negative or there is only a single flex item on the line, this value is identical to flex-start.
Of course, then you won't have half-size spaces on neither end of the flex line. You can insert pseudo-element to have full-size spaces, though.
#container {
display: flex;
justify-content: space-between; /* Instead of space-around */
}
#container::before, #container::after {
content: ''; /* Insert space before the first item and after the last one */
}
.container {
display: flex;
width: 500px;
border: solid black;
justify-content: space-between;
overflow: auto;
margin: 10px 0;
}
.container::before, .container::after {
content: '';
}
.item {
margin: 10px;
background-color: red;
display: table;
font-size: 48pt;
text-align: center;
}
.big > .item {
min-width: 200px;
}
12
34
56
12
34
56