Centering in CSS Grid

后端 未结 7 860
半阙折子戏
半阙折子戏 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:28

    You want this?

    html,
    body {
      margin: 0;
      padding: 0;
    }
    
    .container {
      display: grid;
      grid-template-columns: 1fr 1fr;
      grid-template-rows: 100vh;
      grid-gap: 0px 0px;
    }
    
    .left_bg {
      display: subgrid;
      background-color: #3498db;
      grid-column: 1 / 1;
      grid-row: 1 / 1;
      z-index: 0;
    }
    
    .right_bg {
      display: subgrid;
      background-color: #ecf0f1;
      grid-column: 2 / 2;
      grid_row: 1 / 1;
      z-index: 0;
    }
    
    .text {
      font-family: Raleway;
      font-size: large;
      text-align: center;
    }

    Review my stuff

    Hire me!

提交回复
热议问题