CSS Grid not working in ie11 despite prefixes

前端 未结 1 1538
礼貌的吻别
礼貌的吻别 2021-01-21 11:09

I have the following simple layout example using CSS grid

1条回答
  •  梦毁少年i
    2021-01-21 11:32

    IE does not have auto-flow of grid elements. You need to assign a specific grid position to each grid element, otherwise each non-placed element ends up stacked in 1,1.

    .container {
      width: 100%;
      display: -ms-grid;
      display: grid;
      -ms-grid-columns: 1fr auto 1fr;
      grid-template-columns: 1fr auto 1fr;
    }
    
    .item1 {
      text-align: center;
      background: red;
      color: white;
      padding: 20px;
      -ms-grid-column: 1;
    }
    
    .item2 {
      text-align: center;
      background: green;
      color: white;
      padding: 20px;
      -ms-grid-column: 2;
    }
    
    .item3 {
      text-align: center;
      background: blue;
      color: white;
      padding: 20px;
      -ms-grid-column: 3;
    }
    Item 1
    Item 2
    Item 3

    0 讨论(0)
提交回复
热议问题