我有div
display: flex
和两个孩子说.left
和.right
。
.left
和.right
的内容大小不同。我想为孩子设置相同的高度
这是一个最小的工作代码
.container{
display: flex;
align-items: center
}
.left, .right{
width: 50%;
}
.right{
background: blue;
height: 100%;
}
.left{
background: green;
height: 100%;
}

<div class="container">
<div class="left">
<span>this dis also should have same width as right div</span>
</div>
<div class="right">
orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</div>
&#13;
问题
的 Fiddle 注意:首选解决方案而不应用position: absolute
因为它会破坏我的实际网站
答案 0 :(得分:2)
移除高度:100%;它将解决问题.. flexbox在儿童身上应用它的高度。