1

In this jsfiddle you'll see that there's enough space for a third block under the second block. Is it possible to push the third block under the second block so that there's only two rows?

https://jsfiddle.net/byokdm8o/

.list {
  display: flex;
  flex-flow: row wrap;
  width: 20rem;
}

.item {
  height: 5rem;
  width: 5rem;
  background-color: blue;
  margin: .2rem;
}

.item:nth-child(1) {
  height: 10rem;
  width: 10rem;
}
<div class="list">
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
</div>
Joseph Marikle
  • 76,418
  • 17
  • 112
  • 129
DigitalDisaster
  • 467
  • 3
  • 10
  • 25

3 Answers3

2

If you float the .items left, they'll stack that way.

.list {
  width: 20rem;
}

.item {
  height: 5rem;
  width: 5rem;
  background-color: blue;
  margin: .2rem;
  float: left;
}

.item:nth-child(1) {
  height: 10rem;
  width: 10rem;
}
<div class="list">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
Michael Coker
  • 52,626
  • 5
  • 64
  • 64
0

With such margins between those elements, the solution might be:

.list {
  width: 20rem;
}

.item {
  height: 5rem;
  width: 5rem;
  background-color: blue;
  margin: .2rem;
  float: left;
}

.item:nth-child(1) {
  height: 10rem;
  width: 10rem;
}
Plenarto
  • 639
  • 3
  • 16
-1

you need to use flexbox. i am sure there are other ways as well, but here is an amazing tut on flexbox if you are interested: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

macbeth
  • 138
  • 1
  • 10