【发布时间】:2019-12-02 12:43:44
【问题描述】:
经过几次尝试,当父级(以及和)具有高度:100% 时,很难找到为什么 Firefox 与 flexbox 具有不同的渲染 所有浏览器都毫无问题地呈现页面(即使是 IE11 和 Edge),但 Firefox 无法填充我父 div 的所有高度
<!DOCTYPE html>
<html><head>
<title>TEST</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="TEST" />
<style type="text/css" media="all">
*{
box-sizing: border-box;
}
html, body{
height:100%;
margin:0;
}
</style>
</head>
<body>
<app-root style="display:table; width:100%; height:100%;">
<div style="display: flex; flex-direction: column; height:100%;">
<div style="display: flex; flex-flow: row wrap; flex: 1 1 100%;">
<div style="flex: 1 1 50%; background:yellow;">
<div>DIV 1</div>
</div>
<div style="display: flex; flex-direction: column; flex: 1 1 50%; background:orange; ">
<div>DIV 2</div>
</div>
</div>
<div style="display: flex; flex-direction: row; background:gray; padding:1rem;">
<div>DIV Footer</div>
</div>
</div>
</app-root>
</body>
</html>
期待 Firefox 的渲染与所有浏览器一样。
【问题讨论】:
-
因为
app-root有display: table… 改为block,问题就消失了。 (所以我想说,这并不是一个真正的 flexbox 问题。) -
@ThisisFish 我尝试使用 display:flex 更改示例代码(在 jsfiddle)并将高度 50px 删除为 100%。同样的问题,只有在 Firefox 中有这种奇怪的行为。
标签: html css firefox flexbox height