Look at my attachment. I'm trying to get #relative_test2 to contain it's children #test2 and #test3. Overflow:hidden didn't work, evidently that is just for floats. Is it possible to contain these guys?
border: 1px solid #ccc;
Thanks for the feedback guys. SitePoint forums never fail me when I get stumped. You both got into the nuts bolts of the question. I needed that.
what Paul O'B is saying, the box model height dimension for the relative_test2 div is computing as a zero value in your case. why? by using absolute positioning the elements are taken out of the normal flow. the normal flow being: boxes in boxes in boxes, like matroska dolls. normally, in html, putting boxes in a box (two divs in a div) makes the containing box to expand to contain the other boxes.
putting float or absolute on a child element, makes the parent disregard the box model of it when computing its own.
the clearing mechanism makes the box model for the parent acknowledge the height dimension in the box model for the floating children and adjust.
on the side note, your layout will probably be possible replacing absolute positioning with floating and some additional tinkering.
Absolute elements are removed for the flow.
Although they may be contained by a parent div (one that is positioned) they are removed from the flow at that point and the parent will ignore that absolute element when calculating its height.
Essentially once you absolutely position an element then all elements on the page will think that it doesn't really exist. Although that's not quite true as the positioned parent will create the stacking context for that absolute child but it will not look after that child (i.e. I've got a child but I don't know where he is) .
If you want elements to react with each other then you must keep them in the flow. Floats are removed from the flow but you can use the clear property to regain control of the flow after the float and get things back on track. There is no such mechanism for absolute elements (unfortunately).
If you want horizontal alignment then you should use floats and a clearing mechanism.
Also be careful with relative positioning as relatively placed elements are in fact not moved at all physically. They are only moved visually and the space that they previously occupied is always preserved. That is to say that their movement doesn't interrupt the flow of the document at all and if you move an element with relative positioning everything else on the page will think that it hasn't moved although in its new position it may overlap other elements and leave a gap where it once was.