如何根据其他div高度自动更新div高度?

时间:2022-06-03 12:00:19

I have following setup:

我有以下设置:

<div class="row">
  <div class="col-xs-6">
   <div id="first"> 
   </div>
  </div>
  <div class="col-xs-6">
   <div id="second">
   </div>
  </div>
</div>

In which, div with id first has height property set to auto. I want to be able to automatically detect change in height of the div with id first, and set height of div with id second to x-70px where x is height of div first.

其中,id为id的div首先将height属性设置为auto。我希望能够自动检测具有id的div的高度变化,并将div的高度设置为id,其中id为x-70px,其中x是div的高度。

How can I do this?

我怎样才能做到这一点?

1 个解决方案

#1


1  

Set the second div's height to the first div's height with jQuery.

使用jQuery将第二个div的高度设置为第一个div的高度。

$("#second").height($("#first").height());

#1


1  

Set the second div's height to the first div's height with jQuery.

使用jQuery将第二个div的高度设置为第一个div的高度。

$("#second").height($("#first").height());