【发布时间】:2016-02-10 21:15:52
【问题描述】:
我有两个 id 分别为 firstCard 和 resultCard 的 div。
var newHeight = document.querySelector('#resultCard').clientHeight;
document.querySelector('#firstCard').style.height = newHeight;
alert(document.querySelector('#resultCard').clientHeight);
alert(document.querySelector('#firstCard').clientHeight);
我想将 firstCard 高度调整为与 resultCard 相等。我尝试的方法不起作用,我的警报指示两个不同的值(resultCard 为 432,firstCard 为 400)。
我有什么遗漏吗?
编辑:丢失 = newHeight + "px"; 还必须在我的 CSS 中设置 height: auto。
【问题讨论】: