So my goal is to have 3 children each with 50% width and use flex-wrap: wrap so that the third element goes beneat the first one, however, I also want to have a 10px gap between the first and second children elements and when I add a margin-right: 5px to the first child and margin-left: 5px to the second child, the second child wraps underneath the first one because the extra margin doesn't leave enough space for the second child on the same line.
How am I meant to figure out what % of the width are those 10px taking?
.projects {
width: 100%;
display: flex;
flex-wrap: wrap;
}
.project {
width: 50%
}
.project:nth-child(odd) {
margin-right: 5px;
background-color: red;
}
.project:nth-child(even) {
margin-left: 5px;
background-color: blue;
}
<div class='projects'>
<div class='project'>s</div>
<div class='project'>s</div>
<div class='project'>s</div>
</div>