tags:

views:

50

answers:

6

Hello, I've tried many 2 and 3 column css layouts but none seem to do what I want and I can't figure it out.

What I'm trying to achieve is effectively a two column display with the left side (e.g. 160 pixels wide) having a background of grey, a central section of the page (e.g. 600 pixels) that is white and the remainder of the page to the right having the same as the left (grey). Note, I said grey to make it simple, I actually need something like: background="rgb(220,220,220) url('../images/bg.png') repeat-x;"

Which is a 1 pixel wide, 400 pixel height image to give a 'fade to grey' look.

However, I need the colours of each section to repeat to the bottom of the browser window, not just the height of the heighest div. All the examples I find make use of a footer/div at the bottom to snap the divs to the same height (or similar approach) and if the content is less than the height of the browser it just stops there.

Can anyone help?

btw, I'd rather not cheat by having a huge height giving scroll bars. also, when I say background color grey, I currently have a 400 height white to grey faded 1 pixel wide image that I overlay on top of grey to simulate a gradient.

A: 

Does

<html>
<head>
</head>
<body style='background:#eeeeee'>
  <div id='col1' style='width:160px; background:#eeeeee; height:100%; 
       float:left;'>hi</div>
  <div id='col2' style='width:600px; background:#ffffff; height:100%; 
       float:left;'>hi</div>
</body>
</html>

work for you? It does leave a little gap at the top and bottom, though.

Sam Dufel
Please put the CSS rules inside the `<STYLE>` element
Šime Vidas
Hello, these all work but perhaps I didn't make it quite clear enough (I stated it at the bottom), the background colour while grey needs a background image, e.g. background: rgb(220,220,220) url('../images/bg.png') repeat-x;But this doesn't work. This image is 400px high and makes it look like the top of the left/right columns are fading from white.
neil
also, only works with quirks mode
neil
A: 

I used a 600x1 image: http://vidasp.net/tinydemos/background.html

Šime Vidas
see comment above for Sam Dufel below
neil
A: 

I think Sam is on the right track... Can expand on his solution slightly:

body { width:100%; height:100%; margin:0; padding:0; background:#555; } .column-one { width:160px; height:100%; margin:0; padding:0; background:#555; float:left; } .column-two { width:600px; height:100%; margin:0; padding:0; background:#FFF; float:left; }

Column one here Column two here

timothyclifford
Please put all CSS rules inside the `<STYLE>` element
Šime Vidas
see comment for Sam Dufel below
neil
A: 

Hello, These only work in quirks mode. When I specify xhtml1.0, html 4 transitional, etc it fails. Specifically I'm also using an image:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;

<head>
<style type="text/css">
body
{
    width:100%;
    height:100%;
    margin:0;
    padding:0;
    background:rgb(220,220,220) url('images/bg.png') repeat-x;
}
</style>
</head>
<body>
  <div style="width:160px;;height:100%;float:left;margin:0;padding:0;">

  </div>
  <div style="width:600px;background:#ffffff;height:100%;float:left;margin:0;padding:0;">Column Two</div>
</body>
</html>
neil
A: 

Typically, something like this would be done with a couple of images. The body background image would be a 1-pixel-high image with a 660-pixel-wide white area on a grey (#dcdcdc) background. To prevent multiple vertical white stripes, the image would be very wide (3000 pixels with an optimized pallete saves as a 157-byte PNG). Your current fade background would be applied to a full-width header div. That leaves an ugly spot at the top of the main content area, which you would overpaint by using a negative margin-top (and whatever padding-top you need to compensate) on the outermost div that lives in the main content area.

Stan Rogers
A: 

Here's a simple method. Using an AP box and a wrapper, we can create what you're looking for.

<div id="wrapper">
    <div id="left"></div>
    <div id="center"></div>
</div>

CSS:

#wrapper {
    position: relative;
}

#left {
    width: 100px;
}

#center {
    position: absolute;
    left: 100px;
    top: 0;
    width: 200px;
    background-color: white;
    height: 100%;
}

See: http://www.jsfiddle.net/yijiang/pasUC/

Yi Jiang