Internet Explorer 11 flexbox问题

jay*_*key 5 html css flexbox internet-explorer-11

我编写的代码可在除IE 11之外的所有已测试浏览器中使用。问题似乎在这里:

#wrapper {
    display: -webkit-flex;
    display: -moz-flex;
    display: -ms-flexbox;
    display: -o-flex;
    display: flex;
    -webkit-flex-direction: row;
    -moz-flex-direction: row;
    -ms-flex-direction: row;
    -o-flex-direction: row;
    flex-direction: row;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    width: 100%;
    height: 100%;
    position: relative;
    top: 1em;
}
Run Code Online (Sandbox Code Playgroud)

如果我删除flex,它将变得更易于管理,但是有了它们,它将所有内容缩小到这个长而狭窄的div上,直到永远存在。

如果我在IE 10中进行测试会有所帮助吗?

chr*_*ens 6

您只需要flex:1; 它将解决IE11的问题

#wrapper {
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
display: -o-flex;
display: flex;
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
width: 100%;
height: 100%;
position: relative;
top: 1em;
flex:1;
}
Run Code Online (Sandbox Code Playgroud)

  • “ flex:1”是您在flex容器的子级上设置的,因此,如果“包装器”是_wrapper_,则不会有任何改变...而且由于我们看不到标记,因此我不明白您的做法可能知道这会解决 (3认同)

小智 2

简单地向主体添加 100% 宽度就解决了我的问题。