【发布时间】:2018-10-03 13:08:24
【问题描述】:
我有一排有两列,都是 50%。左边是图片,右边是文字。我的html:
.row{
display:flex;
flex-direction:row;
align-items:center;
}
.cell1, .cell2{
width:50%;
}
.cell2 {
background: green;
}
<div class="row">
<div class="cell1"><img src="https://via.placeholder.com/450x450" ></div>
<div class="cell2">Cell 2</div>
</div>
现在我希望 cell2 的背景为绿色,并且需要 cell2 与 cell1 的高度相同,并且我知道我可以通过为行提供此背景来实现它,但是如何仅使 cell2 的背景为绿色(并且与 cell1) 的高度相同?
【问题讨论】: