Div高度等于另一个div最大高度 [英] Div height equal to another div max-height
本文介绍了Div高度等于另一个div最大高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有3个div:
< div id =main>
< div id =one>< / div>
< div id =two>< / div>
< / div>
- Divone包含一些内容,例如它的高度为300px 。
- Divtwo包含更多或更少的内容,例如它的高度为400px。
- 这两个内容都在变化,它不是静态的,所以我手动无法计算
高度。 - div的样式two也会包含overflow-y:scroll;
ul> - Div "one" contains some content so its height is 300px for example.
- Div "two" contains more or less content so its height is 400px for example.
- Both content is changing, it's not static so I cannot calculate
heights manually. - Style of div "two" will also contain "overflow-y: scroll;"
如何将divtwo创建为与divone相同的高度,可以更小或更大?
这是一个快速的草图:
解决方案使用Javascript,您可以执行以下操作:
document.getElementById(two)。style .height = document.getElementById(one)。clientHeight;
I have 3 divs:
<div id="main">
<div id="one"></div>
<div id="two"></div>
</div>
How to create div "two" to be same height as div "one" which can be smaller or bigger?
Here is a quick sketch:
解决方案
Using Javascript, you could do something like:
document.getElementById("two").style.height = document.getElementById("one").clientHeight;
这篇关于Div高度等于另一个div最大高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文