views:

67

answers:

6

Hello all, I am setting up an asp.net web parts portal for some stuff. I have a [hopefully] really easy question. How can I make the page have 3 major columns?

Right now I have two columns using <div id="leftpanel" style="float: left"> and <div id="rightpanel" style="float: right">. But I cannot figure out how to get a panel in the center. The right panel is basically in the center and there is not a css float: middle/center. So how is a three panel web parts page accomplished?

A: 

A table with 3 columns. Add a div in each column.

Keep the style in the divs..not the table

Ed B
I'm not going to down-vote this, even though I'm not for table-centric design. Prepare to get flamed by any CSS fanatics though!
Noldorin
Tables are for tabular content, not layouts.
danixd
Tables are for whatever I want to use them for.
Ed B
Sometimes Tables are the absolute best option. I <3 Tables.You can add width="33%" to the left and right cells, width="34%" to the center cell.
Fosco
Tables are NEVER the best option for a layout. They are ALWAYS the best option for tabular data, of course. Not only is the markup horrible and harder to understand, but you will have several empty cells to accomodate for horizontal spacing. Plus tables are not as semantic as divs, making them a lot more tricky to style with CSS. HTML5 goes even further by adding tags such as <header> <footer> and <nav>
danixd
Ed B
Might not be the best solution, but it is consistent across browsers. Thanks Ed B!
Jacob Huggart
A: 

I have just been struggling with this myself. Trying to do the 'pure-div' thing and avoid tables. It is haaaaard.

Your leftPanel wants to float left. Your middlePanel also wants to float left. And your rightPanel wants to clear:both

But good luck with the different browsers, div-content size, etc. etc. I ended up doing what EdB suggests :)

n8wrl
A: 
<div class="container">
   <div class="column">
   </div>
   <div class="column">
   </div>
   <div class="column">
   </div> 
</div>
<div class="footer">
</div>

.container{width: 600px;}
.column{float: left; width: 200px;}
.footer{width: 600px; clear: both;}
danixd
My monitor is in 1920x1200 resolution right now; I'd be a bit sad about this design
Michael Mrozek
The width is arbitrary...
danixd
A: 
#wrapper {
    text-align: left;
    margin: 0px auto;
    padding: 0px;
    border:0;
    width: 700px;
}

#header {
    margin: 0 0 15px 0;
    background: yellow;
}

#left-side {
    float: left;
    width: 150px;
}

#right-side {
    float: right;
    width: 150px;
}

#center { 
    float: left;
    width: 56%;
}

#footer {
    background: #A2A2A2;
}

And the corresponding HTML:

<div id="wrapper">
    <div id="header">
        HEADER
    </div>
    <div id="left-side">
        SIDE A
    </div>

    <div id="center">
        CONTENT
    </div>

    <div id="right-side">
        SIDE B
    </div>
    /div>
    <div id="footer">
        FOOTER
    </div>
</div>
A: 

float the first two left and the last one right.

If that doesn't work, and it sometimes won't, then use Ed B's answer.

Chris Lively
A: 

Here's a simple guide to the basic CSS layout types:

http://intensivstation.ch/en/templates/

dave thieben