It's pretty easy to create in the grid, but statically. But how to make dynamic this?
Example:
The parent, grid currently I have 3 grid rows, how to make them automatic higher?
grid-template-rows: repeat(3, 1fr); How to increase 3 by one?
How if, in my case, I have only two blue boxes, set next reds boxes to be like this:
Put latest boxes (light blue) bellow big blue, how if I have one more blue box:
And next, next... My question is: Is this possible in CSS or I must imagine ideas with JS, that can be painful, I think?
Demo code on CodePen is here: CodePen Link
.parent {
display: grid;
grid-template-columns: repeat(6, 1fr);
grid-template-rows: repeat(3, 1fr);
grid-column-gap: 20px;
grid-row-gap: 20px;
}
.small-box {
background:red;
height: 200px;
}
.big-box {
background:blue;
}
.div1 { grid-area: 1 / 1 / 2 / 3; }
.div2 { grid-area: 1 / 3 / 2 / 5; }
.div3 { grid-area: 1 / 5 / 2 / 7; }
.div4 { grid-area: 2 / 5 / 3 / 7; }
.div5 { grid-area: 3 / 5 / 4 / 7; }
.div6 { grid-area: 2 / 2 / 3 / 5; }
.div7 { grid-area: 3 / 2 / 4 / 5; }
<div class="parent">
<div class="div1 small-box">1</div>
<div class="div2 small-box">2</div>
<div class="div3 small-box">3</div>
<div class="div4 small-box">4</div>
<div class="div5 small-box">5</div>
<div class="div6 big-box">7</div>
<div class="div7 big-box">8</div>
<div class="div5 small-box small-box--new">5</div>
</div>


