flex-direction:行-高度相同的子级 [英] flex-direction: row - children of same height
本文介绍了flex-direction:行-高度相同的子级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使 .child
都具有相同的高度。 高度:100%
不起作用, flex-grow:1
也不起作用。建议使用flexbox的方法是什么?
How is it possible to get the .child
s to all have the same height. height: 100%
is not working an neither is flex-grow: 1
. What is the recommended approach for this using flexbox?
.parent {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
width: 800px;
}
.child {
width: 150px;
background-color: green;
border: solid 1px black;
}
<div class="parent">
<div class="child">
Short Text
</div>
<div class="child">
Long Text: Bla bla bla Bla bla bla Bla bla bla Bla bla bla Bla bla bla
</div>
<div class="child">
Short Text
</div>
</div>
推荐答案
.parent {
display: flex;
flex-direction: row;
width: 800px;
justify-content: center;
align-items: stretch;
}
.child {
width: 150px;
background-color: green;
border: solid 1px black;
}
<div class="parent">
<div class="child">
Short Text
</div>
<div class="child">
Long Text: Bla bla bla Bla bla bla Bla bla bla Bla bla bla Bla bla bla
</div>
<div class="child">
Short Text
</div>
</div>
这篇关于flex-direction:行-高度相同的子级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文