我正在尝试制定一个调整大小的函数来增加 div 容器的高度(在每种情况下,这里都是“div.cell”),如果屏幕被挤压得太多以至于内容溢出。每个 div.cell 都有一堆不同的 p。这里只有2个。
<div class="cell panel">
<img src="stills/press/press-logo-c2e2.png" class="general"><p class="one">Panelist - Chicago Comic & Entertainment Expo</p>
<p class="two">[Panel Name Here]</p>
<p class="three"><b>Panel Date/Location:</b> [Time]PM on April 26-28, 2013 at C2E2 (Chicago, Illinois)</p>
<p class="three"><b>Panelists:</b> [Panelists]</p>
<p class="three"><b>Panel Blurb:</b> "[Blurb]"</p>
</div>
<div class="cell panel">
<img src="stills/press/press-logo-wondercon-anaheim.png" class="general"><p class="one">Panelist - WonderCon</p>
<p class="two">[Panel Name Here]</p>
<p class="three"><b>Panel Date/Location:</b> [Time]PM on March 29-31, 2013 at WonderCon (Anaheim, California)</p>
<p class="three"><b>Panelists:</b> [Panelists]</p>
<p class="three"><b>Panel Blurb:</b> "[Blurb]"</p>
</div>
在超级初级且非常错误的jquery中,我希望嵌套来做到这一点,例如:
var pheight = 0;
var divheight = 0;
var biggest = 0;
$("div.cell").each(function (){
divheight=$(this).height();
pheight = 0;
$("p").each(function (){
pheight += $(this).height();
});
biggest = divheight;
if (pheight > biggest) { biggest = pheight };
$(this).css("height",biggest);
})
这不起作用:)任何人都知道我如何将每个 div.cell 更改为其 p 的累积高度(加上缓冲区)