我有一个非常简单的 html 代码:
<body>
<div id="container">
<div id="left">
some text here
</div>
<div id="right">
and some text here
</div>
</div>
</body>
和样式:
div#left {
float: left;
background: #e2e2e2;
}
div#right {
float: right;
background: #1469ab;
}
我想让 div #container 的高度等于它的内容的高度,但现在它实际上是 0。如何实现这种行为?
最佳答案
你应该对容器进行非结构性清理 喜欢 easyclearing http://www.positioniseverything.net/easyclearing.html
否则你也可以指定height: auto;溢出:隐藏
到容器
关于html - div 的高度等于 "0",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4183747/