I want a layout with two right-aligned columns. So, I create three divs (two columns and a wrapper):
<div id="wrapper"> <div id="left"> First column </div> <div id="right"> Second column </div> </div>
I float the left div on the left, the right div on the right and set the correct widths for all three divs:
#wrapper{ width:30em; } #left{ float:left; width:10em; } #right{ float:right; width:20em; }
Everything looks as expected ...
No swimming div http://img690.imageshack.us/img690/5844/rightrightalign.png
.. but then I float the wrapper div to the right, and neither WebKit nor Firefox display horizontal scrollbars if necessary:
Without proper alignment http://img690.imageshack.us/img690/8559/withoutrightalign.png
The same thing happens if I use position: absolute; right:0 position: absolute; right:0
Full HTML document example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <style type="text/css" media="screen"> #wrapper{ width:30em; float:right; } #left{ float:left; width:10em; background: green;} #right{ float:right; width:20em; background: red;} </style> </head> <body> <div id="wrapper"> <div id="left">Left</div> <div id="right">Right</div> </div> </body> </html>
Is there a way to get right-aligned with a double column without losing horizontal scrollbars?
source share