I've a div container (the grey one), with contains some children with a flex
display. The container can scroll vertically.
The height of the gray container should be the same as the window.
.container {
width: 500px;
height: 100vh;
background-color: lightgrey;
padding: 10px;
overflow: auto;
display: flex;
flex-wrap: wrap;
}
.item {
width: 200px;
height: 200px;
background-color: gold;
border: 1px solid orange;
}
<div class="container">
<div class="item" ></div>
<div class="item" ></div>
<div class="item" ></div>
<div class="item" ></div>
<div class="item" ></div>
<div class="item" ></div>
<div class="item" ></div>
</div>
If you run the snippet, you can see the result: each item is near another item and the container scrolls.
The problem is that if I remove some items (their number is dynamic), there is extra space between items. Why?
I don't want this extra space, how can I "remove" it?