PDA

Click to See Complete Forum and Search --> : columns using CSS


mar1300
12-03-2006, 02:19 AM
what's the best way to setup a two/three column layout?? everytime i try everything stacks up on one another. I tried using "float" it just moves to the other side of the page.

xplod_ldg
12-03-2006, 11:28 AM
Try here (http://www.w3.org/2002/03/csslayout-howto).

tZ
12-03-2006, 01:04 PM
One way to do a three is to set up the middle container with a margin left and right that clears the left and right containers. Then you must set the left and right containers width though.

So if you wanted your left container to be 200px and your right to be 100px then you would make your middle containers margin-left 200px and margin-right 100px. That would give you columns which are flush to each other. However, if you wanted there to be say… a 5 px 'border' around each you could set the margin-left to 200+5= 205px and the margin-right to 100+5 = 105 px. Both your left and right containers in any instance will be floated right. This will give you a three column layout with a liquid middle(expands). You will also want to set your display propert to inline for IE when doing this. There is one other thing you need to do for IE so it turns out right but, I can't rmember at this moment.

You could do a two coulmn layout the same way. Just float your left and give it a width then make your middle section's left-margin clear the left and don't set a right margin.

In addition, your middle container come last in the mark up for this to work.

Take this example:


<body>
<div id='wrapper'>
<div id='right'></div>
<div id='left'></div>
<div id='middle'></div>
</div>
</body>

mar1300
12-03-2006, 01:04 PM
Try here (http://www.w3.org/2002/03/csslayout-howto).

thanks!!! that's great...i'll take a look at that for sure.

mar1300
12-03-2006, 01:06 PM
One way to do a three is to set up the middle container with a margin left and right that clears the left and right containers. Then you must set the left and right containers width though.

So if you wanted your left container to be 200px and your right to be 100px then you would make your middle containers margin-left 200px and margin-right 100px. That would give you columns which are flush to each other. However, if you wanted there to be say… a 5 px 'border' around each you could set the margin-left to 200+5= 205px and the margin-right to 100+5 = 105 px. Both your left and right containers in any instance will be floated right. This will give you a three column layout with a liquid middle(expands). You will also want to set your display propert to inline for IE when doing this. There is one other thing you need to do for IE so it turns out right but, I can't rmember at this moment.

You could do a two coulmn layout the same way. Just float your left and give it a width then make your middle section's left-margin clear the left and don't set a right margin.


thanks! I'll give that a try