如果第二个孩子(盒子)不存在,我试图使容器中的顶层孩子自动将高度扩展到100%。这是个好方法吗?
.container{
position:absolute;
display:flex;
flex-direction:column;
justify-content:stretch;
width:200px;
height:300px;
border:1px solid blue;
}
.item{
flex-grow:1;
width:100%;
border:1px solid red;
}
.bar{
position:relative;
height:40px;
background:red;
width:100%;
}
<div class='container'>
<div class='item'>One</div>
<div class='bar'>Two</div>
</div>
o收缩