I have 2 grids, one of them shows 3 columns while the other shows 4 columns. I use different CSS classes to set the --cols
prop.
.base-grid {
--w-max: 175px;
--gap: 0.5rem;
display: grid;
grid-template-columns: repeat(var(--cols), min(var(--w-max), calc(100% - (var(--cols)-1) * var(--gap)) / var(--cols)));
gap: var(--gap);
justify-content: center;
}
.a-grid {
--cols: 3;
}
.b-grid {
--cols: 4;
}
.base-grid>div {
height: 50px;
background: red;
}
<div class="base-grid a-grid">
<div></div>
<div></div>
<div></div>
</div>
<div class="base-grid b-grid">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
This snippet works in Chrome but in Firefox both grids only show 1 column. Why?