2

I have the following simple layout example using CSS grid

.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
}

.item2 {
 text-align:center;
 background:green;
 color:white;
 padding:20px
}

.item3 {
 text-align:center;
 background:blue;
 color:white;
 padding:20px
}
<div class="container">

 <div class="item1">
  Item 1 
 </div>

 <div class="item2">
  Item 2
 </div>

 <div class="item3">
  Item 3
 </div>

</div>

I have prefixed with ie specific prefixes but the grid is not working correctly in ie11. Am I missing a prefix?

Anyone any ideas why?

fightstarr20
  • 11,682
  • 40
  • 154
  • 278
  • 2
    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. – connexo Jul 12 '19 at 09:59
  • [CSS Grid Layout not working in IE11 even with prefixes](https://stackoverflow.com/q/45786788/3597276) – Michael Benjamin Jul 12 '19 at 12:32

1 Answers1

8

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>
connexo
  • 53,704
  • 14
  • 91
  • 128