我正在尝试为jQuery的每次出现唯一地设置.article_description
的div高度和jQuery。我希望将其设置为:
$(".article_title").height() + $(".article_description").height() + $(".article_notes").height() = $(".photo_well").height().
我不想更改
.article_title
,.article_notes
或.photo_well
的高度。这是HTML:
<div class="article_well_main" >
<div class="row" >
<div class="photo_well col-lg-5 col-md-5 col-sm-12">
<img src="<%=asset_path "#{article.image}", alt:''%>" style="width:100%">
</div>
<div class="col-lg-7 col-md-7 col-sm-12" >
<h4 class="article_title"></h4>
<p class="article_description"><%= article.description%></p>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-8 col-xs-8">
<p class="article_location" style="font-size:10px"><%= article.date_published %>  |  <%= link_to article.source, "http://www.#{article.source}", :target => "_blank"%> </p>
</div>
<div class ="article-notes col-lg-4 col-md-4 col-sm-4 col-xs-4">
<i><%=article.notes%></i>
</div>
</div>
</div>
</div>
</div>
JS:
var photo_well_height = $(".photo_well").height();
var article_title_height = $(".article_title").height();
var article_notes_height = $(".article_notes").height();
var article_description_height = photo_well_height - article_title_height - article_notes_height;
$('.article_description').css(height: article_description_height);
最佳答案
尝试以下方法之一:
$('.article_description').css({ height: article_description_height });
$('.article_description').css("height", article_description_height);
$('.article_description').height(article_description_height);
.css(height: article_description_height);
是语法错误。关于javascript - 根据其他div高度设置div高度的动画,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32570085/