0

The last row, there are only two blocks and they got split on the left and right.

Is it possible to let they just aligned normally?

enter image description here

#wrap {
  width: 500px;
  display:flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.item {
  background: red;
  width: 32%;
  height: 20px;
  margin-top:9px;
}
<div id="wrap">
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
</div>

enter image description here

AGamePlayer
  • 7,404
  • 19
  • 62
  • 119

1 Answers1

0

Dont use justify-content: space-between; but add the margin yourself:

#wrap {
  width: 500px;
  display: flex;
  flex-wrap: wrap;
}

.item {
  background: red;
  width: 32%;
  height: 20px;
  margin-top: 9px;
}

.item+.item {
  margin-left: 2%;
}

.item:nth-child(3n+1) {
  margin-left: 0;
}
<div id="wrap">
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
</div>
Fabian S.
  • 2,441
  • 2
  • 24
  • 34