I've a CSS grid with 3 columns based on a 12 columns layout. It could have from 1 single content (1 column 1 row) to many (resulting in a multiple columns multiple rows). The CSS I'm using
.grid {
display: grid;
grid-gap: var(--gap-vertical) var(--gap-horizontal);
grid-template-columns: 1fr 1fr 1fr;
}
doesn't center horizontally che cells, for example, in a case like this:
<div class="grid">
<div>
Content 1
</div>
<div>
Content 2
</div>
</div>
I need the cells to be automatically horizontally centered in any case (from 1 content to many contents on many rows).
Below a case where I've just contents for 2 cells and what I want.
Notice: I have to handle this keeping the CSS Grids (no Flex or other).