I am trying to create a grid layout using flex, where I want to have a 3x3 grid of blocks with a margin between each block.
However, when I add a margin, it changes the layout to 2x5 instead.
Can anyone provide guidance on how to achieve a 3x3 grid with a margin between each block?
.wrap{
max-width: 1000px;
border: 1px solid #ddd;
display: flex;
flex-wrap: wrap;
}
.block{
width: 33%;
height: 100px;
border: 1px solid red;
margin: 5px;
}
<div class="wrap">
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
</div>