I have an flexbox container with a set size, and items which wrap and should be positioned in the container in the total center, but if they overflow the container, the container should scroll vertically. However, their margin causes the first items in the first row to not be fully contained within the scroll container. Does someone know how to fix this?
.container {
width: 400px;
height: 300px;
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
align-content: center;
background-color: blue;
overflow-y: auto;
}
.container > div {
background-color: red;
width: 100px;
height: 100px;
margin: 32px;
}
<div class="container">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>