30 December, 2009

How to center floating divs

This code shows how you can center two floating divs, witch are side-by-side.
1 <html>
2 <head>
3 <style>
4 #floating_div_right { float:right; width:550px; margin-right:auto; border:0; }
5 #floating_div_left { float:left; width:250px; margin-left:auto; border:0; }
6 #center { clear:both; width:800px; margin-left:auto; margin-right:auto; }
7 </style>
8 </head>
9 <body>
10 <div id="center">
11 <div id="floating_div_right">floating_div_right_content</div>
12 <div id="floating_div_left">floating_div_left_content</div>
13 <div id="center">
14 </body>
15 </html>

No comments:

Post a Comment