Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/428.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 如何设置类的新高度=";货柜;要结束数据吗?_Javascript_Jquery_Css_Height - Fatal编程技术网

Javascript 如何设置类的新高度=";货柜;要结束数据吗?

Javascript 如何设置类的新高度=";货柜;要结束数据吗?,javascript,jquery,css,height,Javascript,Jquery,Css,Height,如何将class=“container”的新高度设置为数据末尾 <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.js"></script> <style type="text/css"> .container { background: green; position: relative; } .absolute1 { positio

如何将class=“container”的新高度设置为数据末尾

<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.js"></script>
<style type="text/css">
    .container {
    background: green;
    position: relative;
}
.absolute1 {
    position: absolute;
    background: red;
    float: left;
    width: 200px;
    height: 200px;
}
.absolute2 {
    position: absolute;
    background: red;
    float: left;
    left: 210px;
    width: 200px;
    height: 150px;
}
  </style>

<script type="text/javascript">//<![CDATA[ 
$(window).load(function(){
$( document ).ready(function() {
    $( ".container" ).each(function() {
        var newHeight = 0, $this = $( this );
        $.each( $this.children(), function() {
            newHeight += $( this ).height();
        });
        $this.height( newHeight );
    });
});
});//]]>  

</script>

<div class="container">
       <div class="absolute1">
           Testing absoluteTesting absoluteTesting absoluteTesting absoluteTesting absolute<br />
           Even more testing absolven more testing absolven more testing absolven more testing absolven more testing absolute<br />
       </div>    
           <div class="absolute2">
           Testing absoluteTesting absoluteTesting absoluteTesting absoluteTesting absolute<br />
           Even more testing absolven more testing absolven more testing absolven more testing absolven more testing absolute<br />
       </div>   
</div>

------------------footer text------------------

.集装箱{
背景:绿色;
位置:相对位置;
}
.绝对1{
位置:绝对位置;
背景:红色;
浮动:左;
宽度:200px;
高度:200px;
}
.绝对的2{
位置:绝对位置;
背景:红色;
浮动:左;
左:210像素;
宽度:200px;
高度:150像素;
}
//  
绝对测试绝对测试绝对测试绝对测试绝对测试绝对测试绝对
更多测试免除更多测试免除更多测试免除更多测试免除更多测试免除更多测试免除更多测试免除
绝对测试绝对测试绝对测试绝对测试绝对测试绝对测试绝对
更多测试免除更多测试免除更多测试免除更多测试免除更多测试免除更多测试免除更多测试免除
------------------页脚文本------------------
使用jquery.outerHeight()函数

//顶部和底部填充和边框始终包含在.outerHeight()计算中;如果includeMargin参数设置为true,则还包括边距(顶部和底部)


您将获得元素的新高度,然后使用jquery将此值设置为元素css“数据结束”是什么意思?旁注:您不需要
$(窗口)。load()
$(文档)。ready()
您有一些演示吗?