【问题标题】:Firefox bug on nested flexboxes with overflow [duplicate]带有溢出的嵌套弹性框上的 Firefox 错误 [重复]
【发布时间】:2017-05-11 23:05:45
【问题描述】:

我有一个“复杂”的布局,主要是用 flexbox 制作的,如果你打开这个链接:http://jsbin.com/miyuwuyepu/1/edit?html,css,output 完全滚动到底部,您会在 Chrome 中看到正确的行为,但在 Firefox 中,顶部栏从视图中消失(整个页面滚动)。

这种行为是 Firefox 中的错误吗?有解决方法吗?这是正确的行为,但我错过了什么或做了一些我不应该做的事情?

html,
body,
.container {
  width: 100%;
  height: 100%;
  margin: 0;
  font-size: 10px;
}

.container {
  width: 100%;
  display: flex;
  flex-direction: column;
  margin: 0;
}

.header {
  background-color: yellow;
  width: 100%;
  height: 3rem;
  flex-shrink: 0;
}

.content {
  background-color: aqua;
  width: 100%;
  height: 100%;
  padding-top: 0.1rem;
  display: flex;
  padding: 0;
}

.side-bar {
  background-color: green;
  height: 100%;
  width: 5rem;
  flex-shrink: 0;
}

.boxes {
  overflow: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.box {
  height: 8rem;
  width: 8rem;
  background-color: red;
  margin: 1rem;
  flex-shrink: 0;
}
<div class="container">
  <div class="header"></div>
  <div class="content">
    <div class="side-bar"></div>
    <div class="boxes">
      <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 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 class="box"></div>
      <div class="box"></div>
    </div>
  </div>
</div>

【问题讨论】:

  • 我使用的是 FF 53.0.2(32 位),没有发现问题。黄色标题保持不变。
  • 我在 Mac 和 Ubuntu 上使用 FF 53.x(64 位),我发现两者都有问题。也许你没有一直滚动?您是否尝试过将光标放在绿色栏而不是蓝色部分的顶部来滚动?
  • 您需要将min-height: 0 添加到.content (revised demo)。
  • 这正是我想要的!太感谢了。如果您将其发布为答案,我将很乐意接受。

标签: css firefox flexbox


【解决方案1】:

我可以重现该问题。请更改标题类的 CSS:

.header {
  background-color: yellow;
  width: 100%;
  height: 3rem;
  flex-shrink: 0;
  position: fixed;
}

【讨论】:

  • 它并不能完全解决问题。如果按照您的建议进行操作,则 .content div 将移至顶部,如果我为其添加填充或边距,甚至添加到 .container,问题又回来了
猜你喜欢
  • 2014-06-17
  • 2017-07-08
  • 2021-04-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-23
  • 2017-01-03
相关资源
最近更新 更多