【发布时间】:2017-09-29 05:06:32
【问题描述】:
我有一个简单的布局,在 Chrome 上运行良好,但似乎不适用于 Firefox,我可以使用一些帮助。这是代码:
<div style="height: 100vh; max-height: 100vh; display: flex;flex-direction: column;" class="wrapper">
<div style="flex: 1;">
Top Nav
</div>
<div style="flex: 2; display: flex; flex-direction: row;">
<div style="flex: 1;">
Side Nav
</div>
<div style="flex: 3; overflow: scroll;">
<div style="height: 1500px;">this should scroll...</div>
</div>
</div>
<div class="footer">
footer
</div>
https://plnkr.co/edit/V1Dk9dzEykOQXI3bI1HU?p=preview
在 Firefox 上整个页面滚动,但我只想要 div:
<div style="flex: 3; overflow: scroll;">
作为内容滚动的地方,它在 chrome 上按预期工作,但在 Firefox 上则不然。我究竟做错了什么?
【问题讨论】:
-
将
min-height: 0添加到主弹性容器的第二个子容器中。 -
默认情况下,弹性项目不能小于其内容的大小。初始设置为
min-height: auto。这将防止弹性项目上的溢出(以及滚动条)。 Firefox 遵循 flexbox 规范的这一部分。 Chrome 显然决定忽略它(我相信它在以前的版本中曾经尊重它)。有关详细信息,请参阅重复的帖子。