Display: how to solve the problem that the last two div are not aligned to the left when flex is laid out?

as shown in the following figure, display:flex;justify-content: space-arround;flex-wrap: wrap; is set, but the extra two div are not displayed to the left

clipboard.png

Mar.30,2022

you set justify-content: space-around; this is based on the width average distribution interval
if you want to align to the left, use justify-content: flex-start; , but then you have to manually set the interval
this layout I usually use justify-content: flex-start , then each 25% width of the child elements of the first layer, and then set a padding, so that the interval of each is the same


justify-content: flex-start;

you set justify-content: space-arround;, if you want to keep to the left, you should justify-content: flex-start


you can generate two more empty nodes and keep it four times as many as


this layout can also be arranged with grid


.

.list-item {

  width: 22%;
  margin-right: 4%;
  &:nth-child(4n) {
    margin-right: 0;
  }
}

parent settings

flex: 1;
display: flex;
flex-wrap: wrap;
align-content: flex-start;

solved:
parent node. Game-wrap:

.game-wrap{
    display: flex;
    flex-flow: row wrap;
}

Child node: .game-box {}

.game-box{
   flex: 0 1 250px;
}

clipboard.png

Menu