How do I implement separators between wrapped flex items?
This is the code sample to which I want to add separators:
.a {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}
.b {
background-color: #F6E0E0;
width: 105px;
height: 80px;
}
<div class="a">
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
<div class="b">b</div>
</div>
Each block should be separated from the ones on its left and right by a separator (a div of 1px width and 50px height and a background color for example). However, one block that is on the right edge of the container should not be separated by the next block, which is on the left edge of the container and on the next line. Since the wrapping is dynamic (for the style to be fluid), I can't add separators at specific positions.
I tried using borders or divs but I can't get a correct result. I also tried a workaround by setting justify-content to space-between and adding a margin-right of -1px to the separators, so that the ones on the right get out of the container, but I need justify-content to be set to space-around so this solution is not valid.