CSS Grid not working in ie11 despite prefixes

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

I have the following simple layout example using CSS grid

相关标签:
1条回答
  • 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;
    }
    <div class="container">
    
      <div class="item1">
        Item 1
      </div>
    
      <div class="item2">
        Item 2
      </div>
    
      <div class="item3">
        Item 3
      </div>
    
    </div>

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