Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 按窗口高度的比例更改多个div的高度_Php_Jquery_Css_Height_Each - Fatal编程技术网

Php 按窗口高度的比例更改多个div的高度

Php 按窗口高度的比例更改多个div的高度,php,jquery,css,height,each,Php,Jquery,Css,Height,Each,我在我的网站上使用jquery cycle的幻灯片。 我所有的幻灯片都包含一个名为“cartouche_bottom_inside”的div,我需要根据窗口的高度调整每个div。 我的幻灯片是通过php生成的,因此Basicali如果有这种结构: <div id="slideshow"> <div class="slide"> <div class="cartouche_bottom_inside"> /* my

我在我的网站上使用jquery cycle的幻灯片。 我所有的幻灯片都包含一个名为“cartouche_bottom_inside”的div,我需要根据窗口的高度调整每个div。 我的幻灯片是通过php生成的,因此Basicali如果有这种结构:

<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\u bottom\u inside”divs高度

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);
        }       
}
function margin\u bottom\u cartouche(){
var cartouche_bottom_inside_H=$(“.cartouche_bottom_content”).height();
var margin\u bottom\u cartouche\u add=windowH-cartouche\u bottom\u inside\u H-cartouche\u top\u visible\u H;
if(卡通切底部内部<窗口H){
$(“.cartouche\u bottom\u content”).css(“高度”,cartouche\u bottom\u内部\u H+边距\u bottom\u cartouche\u添加-cartouche\u顶部\u可见\u H);
}       
}
它是有效的,但首先,在我的if语句中,$(“.cartouche\u bottom\u content”).height()获取所有“cartouche\u bottom\u inside”div的总和

然后它将$(“.cartouche\u bottom\u content”).height应用于我的所有div(取决于最高的“.cartouche\u bottom\u content”div)

我想做的是:

第一:首先检查每个div的高度

第二:然后检查每个div的高度是否小于我的窗户高度

第三:然后将高度单独应用于每个div

这意味着我所有的“.cartouche\u bottom\u content”div都有不同的高度

事实上,我正试图找到一种方法来使用foreach语句,比如在php中

有人能帮我吗


非常感谢您的时间,

如果我理解正确,您正在尝试将每个div设置为窗口的视图高度。在这种情况下,如果您感到舒适,您可以查看CSS单元的视图高度和视图宽度,分别设置div的宽度和高度


至于您当前的JS,我不太确定您的代码要实现什么,如果您试图将每个div设置为窗口高度,您就不需要进行所有那些复杂的测量,只需将高度设置为客户端高度?

事实上,我已经有了设置div高度的方法。我要做的是计算独立设置我的所有div(因为它们共享同一个类),然后独立设置我的div的高度…你明白我的意思吗?哦,我明白你现在想做什么了。是的,jQuery中有一个函数允许你单独访问与选择器匹配的每个div。