I am trying to position elements in a flexbox with flex-wrap with gap in between
Ideally the way this should be displayed is:
- On the first row the blue box taking the full width no gaps anywhere
- Second row Red box taking the first 33%, Green box taking the remaining 66%
- There should be 12px gap between the 2 rows
- There should be 12px gap between the Red and Green item without them going on the next row, so their widths should actually become 33% - 6px and 66% - 6px so that there is space left for the gap.
End result should look something like this:
.container {
max-width: 200px;
width: 200px;
display: flex;
flex-wrap: wrap;
gap: 12px;
padding: 0 12px 0 12px;
}
.item1 {
width:33%;
height: 200px;
background-color: red;
}
.item2 {
width:66%;
height: 200px;
background-color: green;
}
.item3 {
width: 100%;
height: 200px;
background-color: blue;
}
<div class="container">
<div class="item3"></div>
<div class="item1"></div>
<div class="item2"></div>
</div>
