Hello i’m trying to create a css grid box with boxes inside. But I either can get the boxes to be the correct size but can’t center the text or get the text centered but can’t get the expected result from the box sizes.
this example shows the text in the center but with a gap in between the boxes.
As for centering things vertically, there is a separate property called align-[items, content or self]. If you apply align-items: center on the container it’ll do the job but unfortunately your items will be shrinked to take only as much height as they need, meaning you’ll lose background. You can try that and see how it looks.
What you can instead do is apply display: grid to the container’s children and then center align them, it’ll do the job.
Like this:
.dag * {
display: grid;
align-items: center;
}
Flex also works if you prefer that.
Now, I’ve noticed that you’re trying to explicitly position many of the items using grid-column and grid-row, there are much easier ways to do things, using grid-template-[columns or rows]. Here is a quick example of a layout made this way.
You can check out these 3 different properties for CSS Grid, using them makes life A LOT easier.