【问题标题】:IE 10 & 11 interpret min-width incorrectly in flexboxIE 10 和 11 在 flexbox 中错误地解释最小宽度
【发布时间】:2016-11-13 10:02:58
【问题描述】:

IE 10 和 IE 11 在与弹性框结合使用时会错误地解释集合 min-width

在下图中,divsflex 都设置为1 1 0%;,但第一个min-width200px 实际上在IE 10 和11 中呈现为250px

小提琴:https://jsfiddle.net/wspwd85h/2/

HTML:

<div id="wrapper">
  <div id="div1"></div>
  <div id="div2"></div>
</div>

CSS:

#wrapper {
  width: 300px;
  height: 100px;
  background: yellow;
  display: flex;
  display: -ms-flexbox;
}

#wrapper div {
  flex: 1 1 0%;
  -ms-flex: 1 1 0%;
}

#div1 {
  background: green;
  min-width: 200px;
}

#div2 {
  background: red;
}

我在flexbugs pages 上找不到任何有关此的信息...

【问题讨论】:

标签: css internet-explorer flexbox internet-explorer-11 internet-explorer-10


【解决方案1】:

您可以将 flex-basis 设置为 auto aka content-size 并设置 div 的 width: 100%

小提琴:https://jsfiddle.net/jofjmwz6/

#wrapper {
  width: 300px;
  height: 100px;
  background: yellow;
  display: flex;
  display: -ms-flexbox;
}

#wrapper div {
  flex: 0 1 auto;
  -ms-flex: 0 1 auto;
  width: 100%;
}

#div1 {
  background: green;
  min-width: 200px;
}

#div2 {
  background: red;
}

基本上,两个 div 都尝试采用父级的全宽,但由于最小宽度,#div1 “获胜”,并且它们不会溢出父级,因为您允许它们缩小:flex-shrink: 1(即@ 987654327@)

你能不能在IE10上测试一下,我只有IE11。

【讨论】:

    猜你喜欢
    • 2018-12-08
    • 2018-09-03
    • 2019-05-05
    • 2023-03-26
    • 2015-08-16
    • 1970-01-01
    • 2016-07-28
    • 2017-05-12
    • 2016-08-13
    相关资源
    最近更新 更多