I want to create a grid of blocks using css flex.
The blocks need to be in three columns and they should be a 3rd of the width of the parent container.
My problem is I need a right margin on the blocks.
The blocks need to be a percentage of the container so I cant use space between.
.block {
border: 1px solid lightgrey;
display: flex;
flex-wrap: wrap;
padding: 5px;
max-width: 900px;
}
.block__item {
background: grey;
height: 20px;
margin-right: 2px;
//margin-bottom: 2px;
width: 33.33%;
}
.block__item:nth-child(3n){
margin-right: 0;
}
<div class="block">
<div class="block__item"></div>
<div class="block__item"></div>
<div class="block__item"></div>
<div class="block__item"></div>
<div class="block__item"></div>
</div>