<body>
<div id="container">
<div id="left">
some text here
</div>
<div id="right">
and some text here
</div>
</div>
</body>
and styles:
div#left {
float: left;
background: #e2e2e2;
}
div#right {
float: right;
background: #1469ab;
}
I want to have the height of div #container equal to heights of it's content, but now it actually 0. How to implement this behavior?
you should apply a non-structural clearing to the container like easyclearing http://www.positioniseverything.net/easyclearing.html
otherwise you can also specify height: auto; overflow: hidden
to the container
add overflow:auto
to your #container
精彩评论