html - Flexbox 的最后一个子边距在 Firefox 中崩溃

标签 html css flexbox

我有一个固定高度和 overflow-y 设置为滚动的 flexbox 容器。在容器内,我有值为 margin-bottom: 2rem 的 child 。

在 Firefox 中,最后一个 child 的边距底部被忽略了,我不明白为什么?它似乎与溢出有关。 Chrome 和 Safari 按预期工作。

JSFIDDLE:https://jsfiddle.net/y7sn0rgb/1/

CSS

    .container {
        display: flex;
        flex-direction: column;
        width: 400px;
        height: 600px;
        background: grey;
        overflow-y: scroll;
    }

    .comment {
        margin-bottom: 2rem;
    }

HTML

  <div class="container">
        <div class="comment">
            The problem with Potential Problem #1 is that it appears to fall apart outside of a flex or grid formatting context. For example, in a standard block layout, the last margin doesn't appear to collapse. So maybe overflow is permitted to cover margins / paddings, regardless of what it says in the spec.
        </div>
        <div class="comment">
            The problem with Potential Problem #1 is that it appears to fall apart outside of a flex or grid formatting context. For example, in a standard block layout, the last margin doesn't appear to collapse. So maybe overflow is permitted to cover margins / paddings, regardless of what it says in the spec.
        </div>
        <div class="comment">
            The problem with Potential Problem #1 is that it appears to fall apart outside of a flex or grid formatting context. For example, in a standard block layout, the last margin doesn't appear to collapse. So maybe overflow is permitted to cover margins / paddings, regardless of what it says in the spec.
        </div>
        <div class="comment">
            The problem with Potential Problem #1 is that it appears to fall apart outside of a flex or grid formatting context. For example, in a standard block layout, the last margin doesn't appear to collapse. So maybe overflow is permitted to cover margins / paddings, regardless of what it says in the spec.
        </div>
        <div class="comment">
            The problem with Potential Problem #1 is that it appears to fall apart outside of a flex or grid formatting context. For example, in a standard block layout, the last margin doesn't appear to collapse. So maybe overflow is permitted to cover margins / paddings, regardless of what it says in the spec.
        </div>
        <div class="comment">
            The problem with Potential Problem #1 is that it appears to fall apart outside of a flex or grid formatting context. For example, in a standard block layout, the last margin doesn't appear to collapse. So maybe overflow is permitted to cover margins / paddings, regardless of what it says in the spec.
        </div>
        <div class="comment">
            The problem with Potential Problem #1 is that it appears to fall apart outside of a flex or grid formatting context. For example, in a standard block layout, the last margin doesn't appear to collapse. So maybe overflow is permitted to cover margins / paddings, regardless of what it says in the spec.
        </div>
        <div class="comment">
            The problem with Potential Problem #1 is that it appears to fall apart outside of a flex or grid formatting context. For example, in a standard block layout, the last margin doesn't appear to collapse. So maybe overflow is permitted to cover margins / paddings, regardless of what it says in the spec.
        </div>
  </div>

最佳答案

margin-bottom 更改为 padding-bottom

关于html - Flexbox 的最后一个子边距在 Firefox 中崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55355106/

相关文章:

javascript - 在 Javascript 中递归调用函数?

html - 如何对齐中心+左/右

javascript - 悬停时模糊整个背景

javascript - JQuery 的竞争条件

css - Bootstrap : Add a button link in the bottom right corner of a thumbnail

html - 在 foreach 中创建具有顶部 div 宽度的 div

html - 将垫子图标放在带有 flex 的 div 的中心?

html - 根据父宽度将 100% 宽度设置为固定元素

html - 包含SVG图片的HTML框与图片的宽高比不匹配

javascript - 外部 JS 文件 + jquery + css