In the markup below, without changing the order of the elements, and without adding additional elements, I would like to fix the width of the sidebar to 300 pixels and float it to the right of #content so that #content and #sidebar have the same top x position (they are aligned beside one another).
For #content, I don't want to specify a width, but rather, I want it to auto expand to fill the available width left over from #sidebar.
In some cases, #sidebar will not be present in the markup, so the CSS will allow that condition and content will just expand/contract nicely to fill the space.
The tricky part is that since #sidebar follows #content in markup, unless #content is given a fixed width less than or equal to the parent container's remaining available width, #sidebar falls below it.
Any ideas?
HTML Code:<div id="main"> <div id="top-widget">This div should span the full width of the parent container</div> <div id="content">This div should float to the left of its sibling "#sidebar" and should take up as much horizonal space as left over after #sidebar's fixed width</div> <div id="sidebar">This div should float to the right of content and be 300 pixels wide.</div> <div class="clearFloats">This div is empty and just clears any floats before the footer section begins</div> </div>Code:#main {width:967px;} #top-widget {clear:both;} #sidebar {float:right; width:300px;} #content {???}









Bookmarks