![](/img/trans.png)
[英]Flexbox IE11 bug: flex child is filling 100% height of parent; won't expand or contract with content
[英]Flexbox not filling height in IE11
我有这个案子:
http://codepen.io/anon/pen/radoPd?editors=110
这是CSS代码:
.wrapper{
background-color: red;
min-height: 100vh;
display: flex;
}
.sidebar{
background: orange;
flex: 0 0 300px;
}
.main{
background-color: green;
overflow-y: scroll;
}
出于某种原因,在IE11上,.sidebar和.main区域都不会填充包装器的整个高度。
这是浏览器之间的不一致。 这是一个错误吗? 我错过了什么吗?
这是一个已知的IE漏洞 ,遗憾的是已被关闭,因为IE Team Won't Fix
并描述如下:
在支持flexbox的所有其他浏览器中,
flex-direction:column
基于flex-direction:column
的flex容器将遵循容器min-height
来计算flex-grow
长度。 在IE10和11-preview中,它似乎只能使用显式height
值。
AFAIK,尽管有这样的描述,当flex-direction
是row
,bug也适用。 正如评论中所提到的,菲利普沃尔顿在这里提出了一个解决方案,其中包括将高度设置为固定值,但这不是OP的选项。
作为一种解决方法,我建议将min-height: 100vh
设置为main
元素:
.wrapper{
background-color: red;
min-height: 100vh;
display: flex;
}
.sidebar{
background: orange;
flex: 0 0 300px;
}
.main{
background-color: green;
min-height: 100vh;
}
笔在这里 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.