2
最小工作示例:http://jsfiddle.net/3qxfknd7/行高或垂直对齐Flexbox的孩子
你可以看到A
和B
均为其各自的div中水平居中,而不是垂直方向。高度是动态的,因此我不能将line-height
设置为font-size
,因为具有较大font-size
的按钮将不得不确定line-height
。接下来,类large
可能会或可能不存在:我不能认为它存在!
我该怎么做?
<div class="button-group">
<div class="button"><span>A</span></div>
<div class="button"><span class="large">B</span></div>
</div>
.button-group {
display: flex;
flex-flow: row nowrap;
align-content: flex-start;
justify-content: flex-start;
}
.button {
flex: 1 0 auto;
text-align: center;
outline: 1px solid red;
}
.button span {
font-size: 20px;
}
.button span.large {
font-size: 40px;
}
将使编辑! – 2015-03-03 10:21:35