【发布时间】:2015-02-10 08:10:12
【问题描述】:
我在我的网站上使用带有 jquery 循环的幻灯片。 我所有的幻灯片都包含一个名为“cartouche_bottom_inside”的 div,我需要使每个 div 适应我的窗口高度。 我的幻灯片是通过 php 生成的,所以基本上如果有这种结构:
<div id="slideshow">
<div class="slide">
<div class="cartouche_bottom_inside">
/* my content */
</div>
</div>
<div class="slide">
<div class="cartouche_bottom_inside">
/* my content */
</div>
</div>
<div class="cartouche_bottom_inside">
/* my content */
</div>
</div>
<div class="slide">
<div class="cartouche_bottom_inside">
/* my content */
</div>
</div>
</div>
使用此 jquery 代码,我可以根据各种自定义变量更改“cartouche_bottom_inside”div 的高度。
function margin_bottom_cartouche(){
var cartouche_bottom_inside_H = $(".cartouche_bottom_content").height();
var margin_bottom_cartouche_add = windowH - cartouche_bottom_inside_H - cartouche_top_visible_H;
if (cartouche_bottom_inside_H < windowH) {
$(".cartouche_bottom_content").css("height",cartouche_bottom_inside_H + margin_bottom_cartouche_add -cartouche_top_visible_H);
}
}
它有效,但首先,在我的 if 语句中,$(".cartouche_bottom_content").height() 得到了我所有“cartouche_bottom_inside”div 的总和。
然后它将 $(".cartouche_bottom_content").height 应用于我所有的 div(取决于最高的 ".cartouche_bottom_content" div。
我想做的是:
1st : 首先检查每个 div 的高度
第二个:然后检查每个 div 的高度是否小于我的窗口高度。
3rd : 然后将高度分别应用到每个 div。
这意味着我的所有“.cartouche_bottom_content” div 将具有不同的高度。
事实上,我正在尝试找到一种方法来创建一个 foreach 语句,例如在 php 中......
谁能帮我解决这个问题?
非常感谢您的宝贵时间,
【问题讨论】:
标签: php jquery css height each