Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.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
Javascript 函数equalHeight,是否设置要应用的最小高度?_Javascript_Jquery_Height_Css Position_Calculated Columns - Fatal编程技术网

Javascript 函数equalHeight,是否设置要应用的最小高度?

Javascript 函数equalHeight,是否设置要应用的最小高度?,javascript,jquery,height,css-position,calculated-columns,Javascript,Jquery,Height,Css Position,Calculated Columns,我已经尝试了一切,但没有javascript,我无法实现设计师给我的糟糕布局 正如你所看到的,我有一个div backgr框,它必须用z-index绝对定位,才能正确地位于保存页面内容的contentuto后面!! 现在,为了解决backgr box的扩展性问题,如果contenuto的内容比边栏barra laterale长,我有以下代码可以工作,但在相反的情况下它不正常,请参见第页: 那么,我如何告诉javascript仅在div边栏barra laterale的最小高度上应用该计算呢 我需

我已经尝试了一切,但没有javascript,我无法实现设计师给我的糟糕布局

正如你所看到的,我有一个div backgr框,它必须用z-index绝对定位,才能正确地位于保存页面内容的contentuto后面!! 现在,为了解决backgr box的扩展性问题,如果contenuto的内容比边栏barra laterale长,我有以下代码可以工作,但在相反的情况下它不正常,请参见第页:

那么,我如何告诉javascript仅在div边栏barra laterale的最小高度上应用该计算呢

我需要帮助。。求你了

function equalHeight(group) {
           tallest = 0;
           group.each(function() {
              thisHeight = $(this).height();
              if(thisHeight > tallest) {
                 tallest = thisHeight = $("#contenuto").height() - 380;
              }
           });
           group.height(tallest);
        }
        $(document).ready(function() {
           equalHeight($(".column"));
        });

这一行可能存在以下问题:

tallest = thisHeight = $("#contenuto").height() - 380;
目前,它正在将变量highest和thisHeight设置为内容区域的高度减去380像素。将其更改为:

tallest = thisHeight;
它会将所有列的大小调整到最高列的高度

编辑:看起来您右侧的列实际上由多个列组成,这些列的类为.barra laterale。在这种情况下,您可能需要采取另一种策略:

// calculate the total height of the content are and sidebar
var contentHeight = $("#contenuto").height();
var sidebarHeight = 0;
$(".barra-laterale").each(function() { sidebarHeight += $(this).height(); })

if (sidebarHeight > contentHeight) {
    $("#contenuto").height(sidebarHeight);
} else {
    // extend the last sidebar column to cover the difference between the 
    // height of the content and the sum of the sidebar heights
    var lastSideBarHeight = $(".barra-laterale").last().height();
    var heightDifference = contentHeight - sidebarHeight; 
    $(".barra-laterale").last().height(lastSideBarHeight + heightDifference) 
}

嗨,克里斯和托马拉克!ehps。。它似乎不起作用!但看看,现在我已经添加了ID巴拉侧翼到长侧边栏,并认为第一侧边栏可以保持为一个固定的高度。380px!这能帮助我们吗?长页: