I'm placing an unknown number of div elements inside of a flex container.
.container {
border: 1px solid red;
display: flex;
flex-flow: row;
flex-wrap: wrap;
gap: 10px;
width: 170px;
}
.element {
flex: 0 0 auto;
height: 50px;
width: 50px;
border: 1px solid blue;
}
<div class="container">
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
</div>
Originally, the width of the container is 80% percents of the window, so its width varies.
I'd like to style each one of the wrapped rows like a shelf, so that there is a bottom-border (and other elements) below all elements in a line. In the example above - there should be 3 shelves, and if the container get's wider - there will be a fewer shelves.
Can I achieve that using CSS only?