Is there a way to automatically create a new row for a specific group of flex children each time they appear in the following structure?
<div class="container">
<div class="portrait">portrait</div>
<div class="portrait">portrait</div>
<div class="portrait">portrait</div>
<div class="landscape">landscape</div>
<div class="landscape">landscape</div>
<div class="portrait">portrait</div>
<div class="portrait">portrait</div>
<div class="portrait">portrait</div>
<div class="portrait">portrait</div>
<div class="landscape">landscape</div>
<div class="landscape">landscape</div>
<div class="landscape">landscape</div>
<div class="portrait">portrait</div>
</div>
CSS:
.container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.portrait {
flex: 1;
background: blue;
height: 300px;
}
.landscape {
flex: 2;
background: red;
height: 150px;
}
Desired layout:
Portrait Portrait Portrait
Landscape Landscape
Portrait Portrait Portrait Portrait
Landscape Landscape Landscape
Portrait
...pattern continues
I have successfully used a div with a "break" class (flex-basis: 100%;) between groups of items (with JavaScript splitting arrays into subarrays), but I am curious if there is a pure CSS solution. The order of portrait and landscape items may vary.