Firefox中Flexbox中的垂直滚动渲染问题

Joh*_*hnB 7 html css firefox css3 flexbox

我想在父项中包含一个flex项,以便它不会溢出父项之外.只有弹性项目应该有一个滚动条(如果需要).

我的样式在Chrome和IE11中运行良好,但不适用于Firefox.我怀疑在flex-basis设置的样式的解释上有所不同#wrapper,但我无法弄清楚为什么Firefox以不同的方式呈现.

这是Chrome中所需的渲染:

Chrome渲染截图

这是Firefox中发生的事情:

Firefox渲染截图

我可以通过添加来应用"胶带"修复#left { height: calc(100vh - 50px); },但如果可能的话,我更愿意确定实际的不一致性.

body, html, h1 {
  padding: 0;
  margin: 0;
}
header {
  background-color: rgba(0, 255, 255, 0.2);
  height: 50px;
}
#main {
  height: 100vh;
  background-color: rgba(0, 255, 255, 0.1);
  display: flex;
  flex-flow: column;
}
#wrapper {
  display: flex;
  flex-grow: 2;
  flex-basis: 0%;
}
#left {
  overflow-y: scroll;
  background-color: rgba(0, 255, 255, 0.2);
  width: 30%;
}
.box {
  margin: 5px 0;
  height: 50px;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.2);
}
Run Code Online (Sandbox Code Playgroud)
<div id="main">
  <header>
    <h1>Header</h1>
  </header>
  <div id="wrapper">
    <div id="left">
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
      <div class="box"></div>
    </div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

Mic*_*l_B 7

这与flexbox规范隐含的最小尺寸算法有关.

这是一个Firefox错误.

添加min-width: 0; min-height: 0#wrapper似乎这样的伎俩:

#wrapper {
    display: flex;
    flex-grow: 2;
    flex-basis: 0%;
    min-height: 0; /* NEW */
    min-width: 0; /* NEW */
}
Run Code Online (Sandbox Code Playgroud)

DEMO


原文如下

目前您已overflow-y: scroll申请#left.

如果你也同样适用overflow-y: scroll#wrapper,垂直滚动在Firefox启动.

至于为什么Firefox解释代码的方式与Chrome不同,我不能说.渲染引擎有其不同之处.我最近解决了IE11和Chrome之间的另一个flexbox解释问题:

更多信息:


归档时间:

查看次数:

1450 次

最近记录:

9 年,11 月 前