css - Div collision after floating -
i have divs , want them following way parent div (topdiv) holds 3 divs float (left, left, right). topdiv not float.
after topdiv have bottomdiv. div not float either. problem topdiv , bottomdiv collides each.
i want this:
div1 div2 div3<br> div1 <br> div4 but get
div1 div2 div3 **div4** <br>div1 here code:
<html> <head> <title>insert title here</title> </head> <body> <div id="topdiv" > <div id = "t1" style="float:left;"> div1 <br> div1 next line </div> <div id = "t2" style="float:left;"> div2 </div> <div id = "t3" style="float:left;"> div3 </div> </div> <div id = "bottomdiv" style=" background-color:red;"> div4 </div> </body> </html> thanks in advance.
unfloated items don't 'contain' floats in layout. set both topdiv , bottomdiv overflow:hidden contain floats.
there other ways of containing floats. in addition overflow: hidden micro clearfix method floating parent container (give width of 100%). more in article simple tips on containing floats.
different methods have different drawbacks pick method works best layout. instance, overflow:hidden solid way go... unless have flyout menu or shouldn't hidden!
Comments
Post a Comment