【问题标题】:Set equivalent size to div with jss使用 jss 将等效大小设置为 div
【发布时间】: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。

【问题讨论】:

    标签: jquery css jscript


    【解决方案1】:
    document.querySelector('#firstCard').style.height = newHeight + "px";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-12
      • 2012-08-23
      • 2018-08-19
      • 2015-02-05
      • 2021-12-27
      • 2014-06-05
      • 2021-12-27
      • 2014-03-31
      相关资源
      最近更新 更多