I have a grid where I want it to work somewhat like it is except when there are only 1 or 2 cells I want it to auto size and not be a set of 3 with the last one holding its cell space. When I set repeat(3, 100px) value to auto-fit then it kills the column layout. I still need it to wrap at 3.
.parent {
background: #f4f4f5;
font-size:2em;
border: 1px solid black;
padding: 20px 0;
text-align: center;
width: 100%;
}
.parent .wrapper {
display: inline-grid;
grid-template-columns: repeat(3, 100px);
box-shadow: 1px 0px 5px 0px rgba(0,0,0,0.75);
grid-auto-flow: row;
background-color: white;
}
.cell {
border: 1px solid gray;
background-color: white;
}
.cell .inner {
display: flex;
justify-content: center;
align-items: center;
width: 100px;
height: 100px;
text-align: center;
}
<div class="parent">
<div class="wrapper">
<div class="cell">
<div class="inner">Cell 1</div>
</div>
<div class="cell">
<div class="inner">Cell 2</div>
</div>
<div class="cell">
<div class="inner">Cell 3</div>
</div>
<div class="cell">
<div class="inner">Cell 4</div>
</div>
</div>
</div>