【问题标题】:Flex Properties Not Working in IE 10 Even With Old Prefix即使使用旧前缀,Flex 属性在 IE 10 中也不起作用
【发布时间】:2018-11-22 04:05:00
【问题描述】:

我创建了一个英雄,其中文本位于图像的左侧,使用 flexbox 自动将文本定位在 div 的中心,相对于图像。

我使用了旧的和新的 IE 前缀来使其能够在最新版本的 IE 上运行,但它似乎不适用于 IE 10。文本 div 似乎延伸到整个列的宽度,在右边的图像后面。关于为什么会发生这种情况的任何想法?

代码:

.hero {
  background-color: #3c763d;
  text-align: center;
}

.flex {
  display: -ms-flexbox;
  display: -moz-flex;
  display: -webkit-box;
  display: -moz-box;
  display: flex;
  -ms-flex-wrap: wrap;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  flex-direction: row;
}

.d-flex {
  -ms-flex-align: center!important;
  -webkit-box-align: center!important;
  align-items: center!important;
  display: -ms-flexbox!important;
  display: -webkit-box;
  display: flex;
  margin-top: 0;
  margin-left: auto;
  margin-right: auto;
  -moz-flex: 1 1 15em;
  -webkit-box-flex: 1;
  -ms-flex: 1 1 15em;
  flex: 1 1 15em;
}

.img-responsive {
  display: block;
  max-width: 100%;
  height: auto;
}
<section class="section hero">
  <div class="container">
    <div class="row flex">
      <div class="col-xs-12 col-md-6 d-flex">
        <div>
          <h2>Headline</h2>
          <p>Paragraph text</p>
        </div>
      </div>
      <div class="col-xs-12 col-md-6">
        <div>
          <img class="img-responsive" src="http://pngplay.com/wp-content/uploads/1/Laptop-PNG-Image.png">
        </div>
      </div>
    </div>
  </div>
</section>

【问题讨论】:

标签: css twitter-bootstrap flexbox internet-explorer-10


【解决方案1】:

Can I Use 注意到 IE10 仅支持弹性框的 2012 syntax。 (它还指出,由于大量已知错误,支持被认为是部分支持。)

对语法文档进行快速扫描表明align-items 不存在,而可能是flex-item-align。此外,您的示例似乎不包含flex-direction

在 3 或 4 年前尝试在大型网络应用程序中使用 flex 时,我们最终只是对所有版本的 IE 使用了 Javascript 变通方法。

【讨论】:

  • 感谢您的反馈和建议!
  • 我实际上尝试添加额外的前缀,包括旧的 -ms-flex-pack 和添加在 IE10 上仍然不起作用,但在所有其他版本上看起来都很好。很遗憾,我可能不得不找出不同的实现方法。
猜你喜欢
  • 2015-11-21
  • 1970-01-01
  • 2018-01-28
相关资源
最近更新 更多