...

View Full Version : How do I float a sidebar inside the main body?



Xax
10-25-2007, 04:33 PM
I'm trying to figure out the best way to float a sidebar inside the main body of my page (not the full height of the main body, just a section in the middle). I'm new to CSS, but I'm thinking I could define a style for a sidebar using margins, but then I'm not sure how this would work inside the main body (would they overlap?). I tried to span a regular ol' table, but the main body text wouldn't display beside it.

Thanks in advance!

vtjustinb
10-25-2007, 04:52 PM
You'd just want to make sure that the sidebar was inside of the main div, and float it right:


<div id="main-content">
<div id="sidebar">
... sidebar stuffs ...
</div>
... main stuffs ...
</div>

EDIT: If you just want it floating to the right of a specific section of your main text (which as I reread your post might of been what you were asking about) just enclose that section in a div:


<div id="main-content">
.. main stuff ..
<div>
.. more main stuff
<div id="sidebar">
.. sidebar ..
</div>
</div>
.. more main stuff ..
</div>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum