There is such code:
.container { display: flex; justify-content: space-between; width: 370px; padding: 0 18px; flex-wrap: wrap; } .container>div { width: 100px; height: 100px; background: red; border: 2px solid black; margin-bottom: 27px; } <div class="container"> <div>1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> </div> When the div blocks inside the container is a multiple of three, then everything is reflected perfectly. But if you remove one of the blocks, then on the last line the blocks will be spread out on the right and left side.
So the question is how to make it so that if there are 5 blocks, then the fifth block would be located under the second one?