I have some containers and their children are only absolute / relatively positioned. How to set the container's height so their children will be inside of them?
Here's the code:
HTML
<section id="foo">
<header>Foo</header>
<article>
<div class="one"></div>
<div class="two"></div>
</article>
</section>
<div style="clear:both">Clear won't do.</div>
<!-- I want to have a gap between sections here -->
<section id="bar">
<header>bar</header>
<article>
<div class="one"></div>
<div></div>
<div class="two"></div>
</article>
</section>
CSS
article {
position: relative;
}
.one {
position: absolute;
top: 10px;
left: 10px;
background: red;
width: 30px;
height: 30px;
}
.two {
position: absolute;
top: 10px;
right: 10px;
background: blue;
width: 30px;
height: 30px;
}
Here's a jsfiddle. I want the "bar" text to appear between 4 squares, not behind them.
Any easy fixes?
Note that I don't know the height of these children, and I can't set height: xxx for containers.