【发布时间】:2017-07-20 10:02:33
【问题描述】:
我有一个button 封装在div 下,结构如下:
HTML:
<div class="parent-container">
<div class="child child-1 col-xs-6">
<button class="btn btn-primary">Customize Feed</button>
</div>
<div class="child child-2 col-xs-6">
<button class="btn btn-default">Really Really Really Really Really Really Long CTA text</button>
</div>
</div>
CSS:
.parent-container {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
}
.child-1 {
order: 2;
}
.child-2 {
order: 1;
}
.child button {
height: 100%;
white-space: normal;
}
.child button {
width: 100%;
}
这两个按钮(无论是长文本还是短文本)都应该占据相同的高度,无论其内容的长度如何。它适用于所有浏览器除了 macOS 中的 Safari。
问题截图 (来自演示):
【问题讨论】:
-
谢谢。希望其他用户回答您的问题。编码愉快。
标签: html css flexbox vertical-alignment