Css trick to conjoin divs.

Posted by Jronny on Stack Overflow See other posts from Stack Overflow or by Jronny
Published on 2009-12-02T03:58:51Z Indexed on 2010/03/28 3:13 UTC
Read the original article Hit count: 992

Is there a way we could conjoin three divs together?

Hello
<div class="mainContainer">
    <div class="LeftDiv"></div>
    <div class="CenterDiv">
        <input id="txtTest" type="text"/>
    </div>
    <div class="RightDiv"></div>
</div>
World!

what we need here is to present the code this way:

Hello<*LeftDiv*><*CenterDiv with the textbox*><*RightDiv*>World

I tried to use float:left on LeftDiv, CenterDiv and RightDiv but the css also affects the mainContainer. I also need to set the LeftDiv's and RightDiv's height and width on the css but I just can't do it without the float.

Thanks in advance.

Edit: Added question - when LeftDiv, CenterDiv and RightDiv are floated-left, why is mainContainer affected? i just want to have the three inner divs conjoined without affecting the parent div's behavior...

© Stack Overflow or respective owner

Related posts about css

Related posts about css-layout