html - Flex 容器的父级在 Firefox 上不调整大小

标签 html css flexbox

我有这个简单的 HTML 设置:

<a>
  <span class='amount'>XX €</span>
  <span class='text'>
    <span>COIN</span>
    <span>foo</span>
  </span>
</a>

fiddle :http://jsfiddle.net/k5fas9yy/2/

我想要的是 float 元素位于 flexbox 的右侧。在 Chrome、Edge、IE11 中运行良好。但是对于 Firefox,a 似乎占据了 flex 容器的宽度,这将 flexbox 置于 float 元素下方。我怎样才能让它成长以正确适应一切?

最佳答案

使用 display:inline-flex 代替 display:flex

* {
  box-sizing: border-box;
}
a {
  color: white;
  background-color: lightblue;
  display: inline-block;
  height: 45px;
  margin: 0;
  padding: 7.5px 15px;
  border: none;
  font-size: 10pt;
}
.amount {
  float: right;
  margin-left: 2rem;
  font-size: 1.6rem;
  margin-top: 10px;
}
.text {
  padding-top: 5px;
  padding-left: 0.3rem;
  display: inline-flex;
  flex-flow: column nowrap;
  align-items: flex-start;
  background-color: pink;
}
<a>
  <span class='amount'>XX €</span>
  <span class='text'>
        <span>COIN</span>
  <span>foo</span>
  </span>
</a>

在 FF 41.0.2 中测试

关于html - Flex 容器的父级在 Firefox 上不调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33277835/

相关文章:

html - CSS-:not(kbd) bug (style is still applying to <kbd> tags)

html - Plotly 无法在 Shiny 的 HTML 功能中工作

css - 如何强制在 Facebook 中呈现等宽字体?

angular - flex 容器和 ngIf 水平居中

html - 标题中的图像阻止导航栏中的链接

javascript - 使用 roundabout.js 时如何知道 StartChild

html - 将 flex 元素定位到 flex 容器的底部

javascript - 我可以应用显示 : flex to a parent and not to a specific child? 吗

html - 元素不会显示,似乎隐藏在背景图像后面?

html - 如何为外部托管的照片指定缩略图的大小?