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.
Asked
Active
Viewed 1,574 times
1

Jan Kowalski
- 205
- 2
- 7
- 14
1 Answers
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