<div class="grid__container">
<div class="grid__item">A</div>
<div class="grid__item">B</div>
<div class="grid__item">C</div>
<div class="grid__item grid__container--nested">
<div class="nested__item grid__item">1</div>
<div class="nested__item grid__item">2</div>
<div class="nested__item grid__item">3</div>
<div class="nested__item grid__item">4</div>
</div>
<div class="grid__item">E</div>
<div class="grid__item">F</div>
<div class="grid__item">F</div>
<div class="grid__item">H</div>
</div>
<div class="grid__container">
<div class="grid__item">A</div>
<div class="grid__item">B</div>
<div class="grid__item">C</div>
<div class="grid__item grid__container--subgrid">
<div class="subgrid__item grid__item">1</div>
<div class="subgrid__item grid__item">2</div>
<div class="subgrid__item grid__item">3</div>
<div class="subgrid__item grid__item">4</div>
</div>
<div class="grid__item">E</div>
<div class="grid__item">F</div>
<div class="grid__item">F</div>
<div class="grid__item">H</div>
</div>
@import url("https://fonts.googleapis.com/css2?family=Exo:wght@600&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100vw;
min-height: 100vh;
font-family: "Exo", Arial, sans-serif;
background-color: #557;
padding: 4rem;
}
.warning {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 2;
display: flex;
justify-content: center;
align-items: center;
padding: 0.5rem;
background-color: #fed7d7;
border-top: 1px solid #f56565;
padding: 10px;
color: #f56565;
}
@supports (grid-template-rows: subgrid) {
.warning {
display: none;
}
}
.grid__container {
height: calc(100vh - 8rem);
max-width: 1024px;
margin: 0 auto;
outline: 3px solid #111;
background: #333;
padding: 1rem;
}
.grid__item {
outline: 4px solid #111;
background: #557;
color: #fff;
font-size: 1.5rem;
text-shadow: 1px 1px 0 rgb(0 0 0 / 0.8);
}
.subgrid__item,
.nested__item {
outline: 2px solid lime;
}
body {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 10px;
}
.grid__container {
display: grid;
min-width: 40vw;
grid-template-columns: repeat(4, [col-start] 1fr [col-end]);
grid-template-rows: repeat(2, [row-start] minmax(100px, auto) [row-end]);
grid-template-areas:
"cell1 cell2 cell3 cell4"
"cell5 cell6 cell7 cell8";
gap: 1rem;
}
.grid__container--nested,
.grid__container--subgrid {
grid-column: 2 / 5;
grid-row: 1 / 2;
display: inherit;
gap: 20px;
padding: 0.5rem;
outline: 4px solid #ccc;
}
.grid__container--nested {
grid-template-columns: inherit;
grid-template-rows: inherit;
}
.grid__container--subgrid {
outline: 4px solid #f36;
grid-template-rows: subgrid;
grid-template-columns: subgrid;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.