Float variable width divs
-
Searched the forum and found nothing if there is any similar post please direct me to it.
I have this code:<html xmlns="https://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <div id="container" style="width:1024px;"> <div id="left" style="position:relative; width:auto; background:#0F0; height:500px; float:left;"></div> <div id="right" style="position:relative; width:200px; background:#C30; height:500px; float:left;"></div> </div> </body> </html>
How can I float those two divs side by side. The thing I want to achieve is: in WordPress I want the #left div to be the container and the #right div to be the sidebar (with widgets) when there are no widgets on the sidebar (the sidebar is inactive) I want the left div to expand all the width of the #container div (1024px) but when the sidebar is active, with widgets on it, I want the sidebar to float left side by side with the content.
The code above does not seem to work. No matter if the sidebar (#right div) is there or not the width of the #left div always stays the same (1024px the size of the #container) and doesn’t let the #right div to float beside it.
Any help would be appreciated. Thank you in advance.
- The topic ‘Float variable width divs’ is closed to new replies.