我使用Javascript:
将两个<div>
带到同一高度
var tallness = $("#first").height();
$("#second").height(tallness);
但是如何管理<div>
id="second"
比id="first"
短20px
提前致谢!
答案 0 :(得分:2)
您只需substract
来自height
值的$("#second").height(tallness-20);
。
var tallness = $("#first").height();
$("#second").height(tallness-20);
console.log("First div height: "+ $("#first").height());
console.log("Second div height: "+ $("#second").height());
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="first">
first<BR>
first<BR>
first
</div>
<div id="second">
second
second
second
</div>
{{1}}