Here the formula
the formula for width flex item with gap
W = 100%/NC - G/NC*NC-1
NC = number of column on the same row
G = gap range
width = (100% of width row / NC) - (G / NC * NC-1)
.flex {display: flex;flex-wrap: wrap;}.gap {--gap: 1em;gap: var(--gap);}.item-four-col {width: calc(100% / 4 - calc(var(--gap)/4*3));background-color: red;}
<div class="flex gap"><div class="item-four-col">1</div><div class="item-four-col">2</div><div class="item-four-col">3</div><div class="item-four-col">4</div><div class="item-four-col">5</div><div class="item-four-col">6</div></div>