div高度取决于另一个div高度 [英] div height depends another div height
本文介绍了div高度取决于另一个div高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个div,其中一个依赖于另一个。
I have two divs that one of them is dependant on the other one.
|Second Div| |First Div|
| | | |
| | | |
| | | |
第一个div的高度已定义:
The height of the first div defined:
height:auto;
我的问题是如何定义第二个div高度, >
My problem is how to define the second div height so it will be like the first.
推荐答案
使用 display:table / table-cell
:
.parent{
display:table;
width:600px; /* some value*/
border: 1px solid black;
}
.left{
display:table-cell;
height: 500px; /* some value*/
background: red;
}
.right{
display:table-cell;
background: blue;
}
<div class="parent">
<div class="left"></div>
<div class="right"></div>
</div>
这篇关于div高度取决于另一个div高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文