Centering in CSS Grid

后端 未结 7 889
半阙折子戏
半阙折子戏 2020-11-21 07:11

I\'m trying to create a simple page with CSS Grid.

What I\'m failing to do is center the text from the HTML to the respective grid cells.

I\'ve tried placing

7条回答
  •  梦谈多话
    2020-11-21 07:19

    Do not even try to use flex; stay with css grid!! :)

    https://jsfiddle.net/ctt3bqr0/

    place-self: center;
    

    is doing the centering work here.

    If you want to center something that is inside div that is inside grid cell you need to define nested grid in order to make it work. (Please look at the fiddle both examples shown there.)

    https://css-tricks.com/snippets/css/complete-guide-grid/

    Cheers!

提交回复
热议问题