The background-color of #container does not show when I set its height to auto. But it does show when I set it to a fixed height like 1000px. I've tried "overflow:auto", but it didn't work. How can I fix it? I do want #container to vertically expand according to its content and I want to show its background color as well. Any idea will be much appreciated!
Here is the HTML:
<div id="container">
<div id="main">
<div id="div1">text text text text text text text text text text text texttexttext text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text</div>
<div id="div2">text text text text text text text text text text text texttexttext</div>
<div class="clear"></div>
</div><!--end of main-->
</div><!--end of container-->
Here is the CSS:
#container {
background-color: rgb(255, 102, 204);
height: auto;
width: 1200px;
position: absolute;
}
#container #main {
background-color: rgb(204, 51, 0);
height: auto;
width: 900px;
position: absolute;
overflow: auto;
}
#container #main #div1 {
background-color: rgb(0, 204, 255);
float: left;
width: 300px;
padding: 5px;
height: auto;
margin: 20px;
}
#container #main #div2 {
background-color: rgb(0, 153, 153);
height: auto;
width: 400px;
float: left;
margin: 10px;
}
.clear {
clear: both;
}