该div#inner1和div#inner2是内部的div#outer,但仍然高度div#outer显示为0像素带height:auto.
如何获得外部div的子元素的高度?
这是我的代码:
#outer {
width: 300px;
height: auto;
background: #ccc;
}
#inner1 {
float: left;
width: 100px;
height: 100px;
background: #f00;
}
#inner2 {
float: left;
width: 100px;
height: 100px;
background: #0f0;
}Run Code Online (Sandbox Code Playgroud)
<div id="outer">
<div id="inner1"></div>
<div id="inner2"></div>
</div>Run Code Online (Sandbox Code Playgroud)