1

How can I detect in my codepen last <div> is wrapped to next row? I want set in this <div> margin-left: 0. It is only example.

Jan Kowalski
  • 205
  • 2
  • 7
  • 14

1 Answers1

1

How about only applying margins to bottom and right of each box.

body {
  display: flex;
  justify-content: center;
}
.container {
  width: 600px;
  height: 400px;
  background: #e9e9e9;
  display: flex;
  flex-flow: row wrap;
  padding: 10px 0 0 10px;
}
.container div {
  background: #a3a3a3;
  width: 125px;
  height: 125px;
  margin: 0 10px 10px 0;
}
<div class="container">
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</div>
DreamTeK
  • 32,537
  • 27
  • 112
  • 171