I am trying to build a grid layout, where just the top-left, top-right, middle-left, and middle-right container make up a perfect square, while everything else should take up the space left. I saw solutions using a "padding-trick" and pseudo-elements to solve this, but only if all elements had to keep a specific aspect ratio.
.grid-container {
display: grid;
height: 100vh;
width: 100%;
grid-template-columns: 0.5fr 0.5fr 1.5fr;
grid-template-rows: 7rem 0.5fr 0.5fr 2fr;
gap: 1rem;
}
.grid-container > * {
background-color: #454545;
}
.grid-header {
grid-area: 1 / 1 / 2 / 4;
}
.top-left {
grid-area: 2 / 1 / 3 / 2;
}
.top-right {
grid-area: 2 / 2 / 3 / 3;
}
.middle-left {
grid-area: 3 / 1 / 4 / 2;
}
.middle-right {
grid-area: 3 / 2 / 4 / 3;
}
.bottom-left {
grid-area: 4 / 1 / 5 / 3;
}
.bottom-right {
grid-area: 2 / 3 / 5 / 4;
}
<div class="grid-container">
<div class="grid-header"></div>
<div class="top-left"></div>
<div class="top-right"></div>
<div class="middle-left"></div>
<div class="middle-right"></div>
<div class="bottom-left"></div>
<div class="bottom-right"></div>
</div>
How could I achieve this while still being able to make it responsive?