【问题标题】:CSS Grid not working in ie11 despite prefixes尽管有前缀,但 CSS Grid 在 ie11 中不起作用
【发布时间】:2019-11-22 01:33:09
【问题描述】:

我有以下使用 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 中无法正常工作。我是否缺少前缀?

有人知道为什么吗?

【问题讨论】:

标签: html css css-grid


【解决方案1】:

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>

【讨论】:

    猜你喜欢
    • 2014-10-26
    • 2018-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-23
    相关资源
    最近更新 更多