I'm attempting to design a layout that has a unique structure:
https://i.sstatic.net/dCLoPm.png
The blue rectangles are represented by divs
. It's like a 3x3 grid
, but with spaces in the 3rd and 4th columns of the grid.
How can I incorporate these gaps using CSS grid to achieve this particular design? I've experimented with flexbox
, but couldn't quite reach the desired outcome, so I'm hoping a grid
layout will provide the solution.
Below is the code I have been working with:
.container{
border: 1px solid;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr;
gap: 0px 0px;
grid-template-areas:
". . ."
". . .";
}
.item{
border: 1px solid lightgrey;
padding: 10px;
}
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
</div>