I have a container grid to center the child inline-grid element. However, I'm unable to have auto-fill/auto-fit to take as many columns as there can fit. The grid items have a specified width/height.
It is possible to have the inline-grid take as many columns if specified directly, but that is not what I want.
If it's possible doing this with flex it would be okay, even though I prefer using grid.
I want the grid to be CSS ONLY. Do NOT post answers using JavaScript.
body, html {
margin: 0;
height: 100%;
}
.container {
display: grid;
background: red;
height: 100%;
}
.grid {
background: green;
height: 100%;
display: inline-grid;
grid-template-columns: repeat(auto-fill, minmax(100px, 100px));
margin: auto;
}
.item {
background: blue;
}
<div class="container">
<div class="grid">
<div class="item item1"></div>
<div class="item item2"></div>
<div class="item item3"></div>
</div>
</div>