【发布时间】:2020-03-15 20:40:28
【问题描述】:
我整理了以下示例。它适用于所有主流浏览器,但不适用于 IE11。内容 div 溢出 flex 容器(没有滚动条)并向下推页脚。有什么建议?
html,
body {
padding: 0;
margin: 0;
}
.c1 {
border: 1px solid blue;
display: flex;
flex-direction: column;
max-width: 500px;
max-height: 100px;
}
.h,
.f {
flex: 0 0 auto;
}
.b {
border: 1px solid red;
flex: 1 1 auto;
overflow: auto;
}
<div class="c1">
<header class="h">header</header>
<div class="b">What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type
specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<footer class="f">footer</footer>
</div>
【问题讨论】:
-
IE11 在弹性容器上使用
max-*和min-*属性时存在一个已知错误。本质上,弹性容器会忽略它们。解决方案是将容器也变成一个弹性项目。将display: flex添加到父级。您还需要将width: 100%添加到孩子以处理另一个错误。 jsfiddle.net/jq5eym8x
标签: html css flexbox internet-explorer-11