* {
margin: 0;
padding: 0;
}
.cnt {
display: flex;
margin: 50px;
background: #ffff00;
justify-content: space-between;
flex-wrap: wrap;
}
.cnt div {
width: 100px;
height: 100px;
background: #999;
margin: 10px;
}
.cnt::after {
content: '';
width: 100%;
}
.flex-item:nth-child(6) {
order: 1;
}
<div class="cnt">
<div class="flex-item one"></div>
<div class="flex-item two"></div>
<div class="flex-item three"></div>
<div class="flex-item four"></div>
<div class="flex-item five"></div>
<div class="flex-item six"></div>
</div>
The problem I have is that I can break line only on the last item... How am I actually able to brake line whenever I want it to? For example, if I want to break line after class .two
, how can I do it?
EDIT
I'm an idiot. This is actually how you do it. You just need to pass the items you want to be in the next order
. Obviously you may do this only once.
So, to break line in the second box, you need to pass the .three
, .four
, .five
and .six
to order: 1
. See here: https://jsfiddle.net/r33muub3/4/
I changed the justify-content
to left
so it will be much more obvious