I want the red box to be on the 2nd row, but then i want the divs that are defined after it, to continue on the first line, so that all the black boxes essentially wrap around the black box. Can this be achieved with flexbox?
It should look like this:
+---+---+---+---+---+
| 1 | 2 | 3 | 5 | 6 |
+---+---+---+---+---+
| 4 |
+---+---+---+---+---+
| 7 | 8 | 9 |10 |11 |
+---+---+---+---+---+
|12 |13 |
+---+---+
* {
box-sizing: border-box;
}
.container {
display: flex;
flex-wrap: wrap;
}
.a {
border: 1px solid black;
height: 50px;
width: 20%;
}
.b {
border: 1px solid red;
height: 50px;
width: 100%;
}
<div class="container">
<div class='a'>1</div>
<div class='a'>2</div>
<div class='a'>3</div>
<div class='b'>4</div>
<div class='a'>5</div>
<div class='a'>6</div>
<div class='a'>7</div>
<div class='a'>8</div>
<div class='a'>9</div>
<div class='a'>10</div>
<div class='a'>11</div>
<div class='a'>12</div>
<div class='a'>13</div>
</div>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…