I have a solution using display: grid
.
Achieving the required layout with the below two UI states
The layout is created by having a major container grid-container
with three sections leftSide
, topSide
and bottomSide
. Inside the latter, there is a secondary container which is also a grid container with the most important property being:
grid-auto-flow: columns;
Finally, we have a media query in which we have a two-column grid.
The complete code is:
.grid-container {
display: grid;
grid-template-areas:
'leftSide topSide'
'leftSide bottomSide';
grid-template-columns: 1fr 3fr; /* change proportions here */
grid-template-rows: auto auto;
height: 100vh;
width: 100%;
}
.bottom-container {
grid-area: bottomSide;
display: grid;
grid-template-rows: auto auto;
grid-auto-flow: column;
}
@media (max-width: 720px) {
.bottom-container {
grid-template-columns: 1fr 1fr;
grid-auto-flow: initial;
}
}
.box {
display: block;
border: 1px solid red;
padding: 10px;
text-align: center;
}
.box1 {
grid-area: leftSide;
}
.box2 {
grid-area: topSide;
}
<div class="grid-container">
<div class="box box1">1</div>
<div class="box box2">2</div>
<div class="bottom-container">
<div class="box">3</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">5</div>
<div class="box">6</div>
<div class="box">6</div>
<div class="box">7</div>
<div class="box">7</div>
<div class="box">8</div>
<div class="box">8</div>
</div>
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…