Consider the following html 2 cols structure:
<div id="container"> <div class="left">some text</div> <div class="right">some text</div> </div>
CSS
#container { overflow: hidden; } .left { float: left; width: 200px; background: red; } .right { overflow: hidden; background: green; }
Same code in jsFiddle - http://jsfiddle.net/vny2H/
So we have 2 columns. The width of the left column is fixed, the width of the right is liquid. If we remove the left column from html, the right column will stretch 100% of the length of the parent # container.
Question: can we change the order of the left and right columns? (I need this for SEO)
<div id="container"> <div class="right"></div> <div class="left"></div> </div>
Thanks.
Added
There is one interesting method for achieving what I want, but the fixed column becomes not removable. The method is based on negative margin. http://jsfiddle.net/YsZNG/
HTML
<div id="container"> <div id="mainCol"> <div class="inner"> <p>Some text</p> <p>Some text</p> <p>Some text</p> <p>Some text</p> </div> </div> <div id="sideCol"> <p>Some text</p> <p>Some text</p> <p>Some text</p> <p>Some text</p> </div> </div>
CSS
#container { overflow: hidden; width: 100%; } #mainCol { float: right; width: 100%; margin: 0 0 0 -200px; } #mainCol .inner { margin: 0 0 0 200px; background: #F63; } #sideCol { float: left; width: 200px; background: #FCF; }
So, we have 2 ways:
- Using "float" for a fixed column and "overflow: hidden" for fluid. The fixed column becomes removable. But the liquid one takes second place in the code.
- Using a negative field. The liquid column comes first in the code. But fixed is not removable.
Is there a third way when the fixed column is removable and the liquid column is the first in the code?
Added
A half solution was suggested by @lnrbob. The main idea is to use table divs. http://jsfiddle.net/UmbBF/1/
HTML
<div id="container"> <div class="right">some text</div> <div class="left">some text</div> </div>
CSS
#container { display: table; width: 100%; } .right { display: table-cell; background: green; } .left { display: table-cell; width: 200px; background: red; }
This method is suitable when a fixed column is placed on the right side of the site. But if we need it on the left, this is impossible to do.