Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.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 使内部div与容器的高度相同_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 使内部div与容器的高度相同

Javascript 使内部div与容器的高度相同,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我在这个论坛和其他许多地方搜索了很多解决方案,但没有找到一个优雅的解决方案。有些人建议使用表格布局,其他人则提出其他建议,但我想要一个干净的解决方案。我正在使用twitter引导,这就是问题所在 <div class="row"> <div class="col-lg-3"> Side Bar Content Here </div> <div class="col-lg-9"> Main Content of the page </div&

我在这个论坛和其他许多地方搜索了很多解决方案,但没有找到一个优雅的解决方案。有些人建议使用表格布局,其他人则提出其他建议,但我想要一个干净的解决方案。我正在使用twitter引导,这就是问题所在

<div class="row">
<div class="col-lg-3">
Side Bar Content Here
</div>

<div class="col-lg-9">
Main Content of the page
</div>
</div>

这里的侧栏内容
页面主要内容
我在侧栏上使用背景色。现在问题是设置边栏的高度等于容器的高度,以便侧边栏不会在中间折断。因为右边的内容可以是从几个字到几页的任何内容,所以我不能将任何固定高度设置为col-lg-3。高度:由于webkit中的错误,100%无法工作

我正在寻找一个javascript解决方案或jquery中的东西,它将计算容器div(row)的高度,并将该高度设置为col-lg-3,以便背景从上到下覆盖。这是许多人面临的问题,我看到许多问题都没有很好的答案。所以这会让很多人停滞不前

干杯 Ahmar

编辑: 如果您不在乎使用js,您可以使用:

var rowheight=$(“.row”).height()
获取行的高度

和使用:
$(.row div”).height(rowheight)应用于它的子div

小提琴:

编辑: 如果您不在乎使用js,您可以使用:

var rowheight=$(“.row”).height()
获取行的高度

和使用:
$(.row div”).height(rowheight)应用于它的子div


FIDLE:

将背景设置为容器(.row)。将背景设置为容器(.row)。
.row{
position:relative;
}
.col-lg-3{
position:absolute;
height:100%;
}