尽管有前缀,CSS 网格在 ie11 中不起作用

2023-12-04

我有以下使用 CSS 网格的简单布局示例

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

我已使用 ie 特定前缀作为前缀,但网格在 ie11 中无法正常工作。我缺少前缀吗?

有人有什么想法吗?


IE 没有网格元素的自动流动。您需要为每个网格元素分配特定的网格位置,否则每个未放置的元素最终都会堆叠在 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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

尽管有前缀,CSS 网格在 ie11 中不起作用 的相关文章