【问题标题】:How to fix flexbox issue with IE?如何解决 IE 的 flexbox 问题?
【发布时间】:2018-08-06 12:40:57
【问题描述】:

我们正在使用 Flexbox 创建一个网格系统,发现<div class="flex-row"> 中的元素在除 IE 11 之外的所有浏览器中都可以正常工作。

我们如何修复元素以使文本使框正常展开?

.flex-row {
  display: flex;
  flex: 1 1 100%;
  flex-direction: row;
  flex-wrap: wrap;
}

.flex-col {
  margin: 6px;
  padding: 16px;
  background-color: black;
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1 1 0px;
  flex-direction: column;
  color: white;
}

@media (max-width:767px) {
  .flex-col {
    flex-basis: calc(50% - 24px);
  }
}

@media (max-width:460px) {
  .flex-col {
    flex-basis: 100%;
  }
}
<div class="flex-row">
<div class="flex-col">Assertively negotiate interoperable portals without cross functional process improvements. Dramatically incentivize tactical best practices with.</div>
<div class="flex-col">Seamlessly grow competitive.</div>
<div class="flex-col">Distinctively optimize user-centric mindshare vis-a-vis plug-and-play infomediaries. Seamlessly optimize impactful solutions and enabled infrastructures.</div>
<div class="flex-col">Dynamically extend flexible catalysts for change via pandemic supply chains. Efficiently.</div>
</div>

IE 的当前行为:

期望的结果

【问题讨论】:

    标签: html css internet-explorer flexbox


    【解决方案1】:

    我认为您将 flex-items 的属性与 flex-containers 混淆了。请仔细检查。

    无论如何,由于 flexbox 和 IE 的众多错误之一,您的代码无法正常工作。似乎 align-items: center;你的弹性列是罪魁祸首。只需将其删除即可。

    .flex-row {
      display: flex;
      flex: 1 1 100%;
      flex-direction: row;
      flex-wrap: wrap;
    }
    
    .flex-col {
      margin: 6px;
      padding: 16px;
      background-color: black;
      display: flex;
      justify-content: center;
      flex: 1 1 0px;
      flex-direction: column;
      color: white;
    }
    <div class="flex-row">
      <div class="flex-col">Assertively negotiate interoperable portals without cross functional process improvements. Dramatically incentivize tactical best practices with.</div>
      <div class="flex-col">Seamlessly grow competitive.</div>
      <div class="flex-col">Distinctively optimize user-centric mindshare vis-a-vis plug-and-play infomediaries. Seamlessly optimize impactful solutions and enabled infrastructures.</div>
      <div class="flex-col">Dynamically extend flexible catalysts for change via pandemic supply chains. Efficiently.</div>
    </div>
    (我已经删除了仅用于 SO sn-p 目的的媒体查询)

    您真的需要将您的 flex-columns 作为列方向的 flex-containers 吗?如果是这样,你真的需要它们是 align-items:center 吗?

    【讨论】:

    • @FacundoCarrodini align-items center 用于居中对齐各自列中的项目,无论高度如何
    • 删除对齐项后,它确实解决了问题并保持在中心,谢谢
    • @drupi17 align-items:stretch (default) on your .flex-row + justify-content:center on your .flex-colum 正在为你解决这个问题;)
    猜你喜欢
    • 1970-01-01
    • 2012-05-24
    • 1970-01-01
    • 2014-06-08
    • 1970-01-01
    • 1970-01-01
    • 2010-09-17
    • 2010-10-23
    • 2015-09-03
    相关资源
    最近更新 更多