The blue box is fixed size with 100px x 100px. The margin between boxes is dynamic but minimum 10px. under this situation. The row should be fit with the boxes with "The more the better" rule. Say, the margin between boxes is (A). I would like the padding of grid container (B) is two times to (A). If width of (A) is 20px then width of (B) is 40px.
and The scrollbar in (B) should be align center to (B).
body{
overflow: hidden;
}
.container {
display: grid;
width: 100%;
gap: 10px;
overflow-y: auto;
justify-content: space-evenly;
grid-template-columns: repeat(auto-fit, 100px);
}
::-webkit-scrollbar {
width: 4px;
background-color: transparent;
}
::-webkit-scrollbar-thumb {
background-color: rgba(0, 0, 0, 0.4);
background-color: var(--scrollbar-color, rgba(0, 0, 0, 0.4) );
width: 4px;
border-radius: 10px;
}
.box {
width: 100px;
height: 100px;
display: inline-flex;
background-color: blue;
}
<div class="container">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<!-- many boxes below -->
</div>
