html - Firefox 中的 flexbox 溢出容器

标签 html css firefox flexbox

<分区>

我正在处理 flexbox 布局,我遇到了一个问题,即 flex 元素将仅在 firefox 中溢出容器。这是我能想到的最精简的示例(抱歉,它不是 super 小的,我不确定是什么导致了这个问题,所以很难知道我可以删除什么):

<div class="css-190tu11">
  <h1 class="css-1qqir8k">Blah</h1>
  <div class="css-131b9cy">
    <div class="css-1suni8j">
      <a class="css-yq2t95" href="some-url">
        <span class="icon icon-register css-nwymqb" aria-hidden="true"></span>
        <h2 class="css-1892n22">Title</h2>
        <div class="css-kgza95">Description</div>
      </a>
      <div class="css-kujdaf">
        Some special thing
      </div>
    </div>
    <div class="css-1suni8j">
      <a class="css-yq2t95" href="some-url">
        <span class="icon icon-register css-nwymqb" aria-hidden="true"></span>
        <h2 class="css-1892n22">Title</h2>
        <div class="css-kgza95">Description</div>
      </a>
      <div class="css-dkez8"></div>
    </div>
    <div class="css-1suni8j">
      <a class="css-yq2t95" href="some-url">
        <span class="icon icon-register css-nwymqb" aria-hidden="true"></span>
        <h2 class="css-1892n22">Title</h2>
        <div class="css-kgza95">Description</div>
      </a>
      <div class="css-dkez8"></div>
    </div>
    <div class="css-1suni8j">
      <a class="css-yq2t95" href="some-url">
        <span class="icon icon-register css-nwymqb" aria-hidden="true"></span>
        <h2 class="css-1892n22">Title</h2>
        <div class="css-kgza95">Description</div>
      </a>
      <div class="css-dkez8"></div
    </div>
  </div>
</div>

还有 CSS:

.css-190tu11,
[data-css-190tu11] {
  padding: 12px 48px 24px 48px;
  border: solid 1px #e0e0e0;
}
.css-1qqir8k,
[data-css-1qqir8k] {
  font-size: 24px;
  font-weight: 300;
  margin-bottom: 18px;
  margin-top: 0;
}
.css-131b9cy,
[data-css-131b9cy] {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
}
.css-131b9cy > *,
[data-css-131b9cy] > * {
  flex: 0 1 auto;
  margin-left: 0;
  margin-right: 0;
}
.css-131b9cy > *:not(:first-child),
[data-css-131b9cy] > *:not(:first-child) {
  margin-left: 10px;
}
.css-131b9cy > *:not(:last-child),
[data-css-131b9cy] > *:not(:last-child) {
  margin-right: 10px;
}

.css-1suni8j,
[data-css-1suni8j] {
  display: flex;
  background-color: white;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  max-width: 186px;
  min-width: 120px;
  height: 240px;
}
.css-1suni8j > *,
[data-css-1suni8j] > * {
  margin-top: 0;
  margin-bottom: 0;
}
.css-1suni8j > *:not(:first-child),
[data-css-1suni8j] > *:not(:first-child) {
  margin-top: 10px;
}
.css-1suni8j > *:not(:last-child),
[data-css-1suni8j] > *:not(:last-child) {
  margin-bottom: 10px;
}

.css-yq2t95,
[data-css-yq2t95] {
  flex: 1;
  justify-content: space-between;
  flex-direction: column;
  display: flex;
}
.css-yq2t95 > *:last-child,
[data-css-yq2t95] > *:last-child {
  flex: 0 1 auto;
}
.css-yq2t95 > *,
[data-css-yq2t95] > * {
  margin-top: 0;
  margin-bottom: 0;
}
.css-yq2t95 > *:not(:first-child),
[data-css-yq2t95] > *:not(:first-child) {
  margin-top: 5px;
}
.css-yq2t95 > *:not(:last-child),
[data-css-yq2t95] > *:not(:last-child) {
  margin-bottom: 5px;
}

.css-nwymqb,
[data-css-nwymqb] {
  transition: all 0.5s ease;
  border-radius: 50%;
  display: block;
  margin-left: auto;
  border: 1px solid #0070ba;
  height: 60px;
  width: 60px;
  font-size: 30px;
  line-height: 54px;
  margin-right: auto;
}

.css-1892n22,
[data-css-1892n22] {
  font-weight: normal;
  flex: 0 1 auto;
  color: inherit;
  padding: 0;
  font-size: 16px;
  height: 80px;
}
.css-kgza95,
[data-css-kgza95] {
  font-weight: normal;
  font-size: 11px;
  color: #333333;
  height: 76px;
}
.css-kujdaf,
[data-css-kujdaf] {
  min-height: 36px;
  background-image: linear-gradient(93deg, #1446a0, #0070ba);
  width: 100%;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
}
.css-dkez8,
[data-css-dkez8] {
  min-height: 36px;
}

这是它在 Chrome 和 Safari 中的样子(这是我想要的样子):

Chrome and Safari

这是它在 Firefox 中的样子:

Firefox

甚至 Internet Explorer 10 也能以我想要的方式显示它! (无法在代码笔中验证,因为我删除了供应商前缀,但它在我的应用程序中有效)。

这是 a codepen为此。

感谢您的帮助!

最佳答案

Turns out溢出的元素需要有一个 min-height: 0 。我不确定为什么,但是通过将它放在 .css-yq2t95 上,一切都运行良好。感谢大家的参与!

关于html - Firefox 中的 flexbox 溢出容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43130470/

相关文章:

css - 如何在规模上坚持div溢出

css - Firefox 中的页面渲染问题

javascript - 无法让我的 openlayers map 出现在网页上

html - Bootstrap : Select Tag Cutting off texts below

c# - 在 C# 中获取 Yahoo 结果页面的标题和 URL

javascript - Mac OS X——如果 chrome/firefox/safari 处于全屏模式,我可以用 javascript 检测吗?

css - Firefox - CSS 断字 : break-all unstable

javascript - jQuery 通过关闭/隐藏一次切换一个元素

Javascript 表单验证不显示错误

css - 如何将列表项和列表内容与空格对齐?