【发布时间】:2017-01-16 04:05:56
【问题描述】:
我有以下代码在 Chrome 和 IE 中按预期工作。但是在 Firefox 中,每个按钮中的第二个跨度显示在自己的行中。为什么是这样?如何解决这个问题?
https://jsbin.com/banafor/4/edit?html,css,output
期望(在 IE 中,Chrome 可以):
失败(在 Firefox 中):
.buttons-pane {
width: 150px;
height: 400px;
}
button {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
button .title {
background-color: yellow;
}
button .interest {
background-color: lightyellow;
}
<div class="buttons-pane">
<button type="button">
<span class="title">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet</span>
<span class="interest">Short</span>
</button>
<button type="button">
<span class="title">Neque porro quisquam</span>
<span class="interest">LongInterest</span>
</button>
<button type="button">
<span class="title">Vix aeterno vocibus vituperatoribus eu. Nec regione fuis</span>
<span class="interest">Keyword</span>
</button>
</div>
PS:如有必要,我不介意将跨度更改为其他内容:)
【问题讨论】:
-
将
span包装在div中,然后将css 属性display:table;添加到div 并将css 属性display:table-cell;vertical-align:middle;添加到两个span。链接:jsbin.com/qiniwozilu/edit?html,css,output