CSS Grid not working in ie11 despite prefixes

牧云@^-^@ 提交于 2019-12-04 05:43:35

问题


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?


回答1:


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>


来源:https://stackoverflow.com/questions/57004310/css-grid-not-working-in-ie11-despite-prefixes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!