Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

centering web page and background colour

Status
Not open for further replies.

sambo80

Technical User
Oct 4, 2005
11
GB
Hi

I think this is a quick and easy one, just that I can't get it to work.

At the moment I have my main web page in a <div tag> as follows:

Code:
<body>
<div id="container">
<table...........

WEB PAGE

</table>
</div>
</body>

My css for the container ID is as follows:

Code:
body {
  text-align: center;
  }

#container {
  margin: 0 auto;
  width: xxxpx;
  text-align: left;
  }

The web page centers ok, but I want to add some colour to the spaces on the outside. I tried to add another div container before this main div (for the left side) and made it a different colour, but it filled the white background tin the main page with that colour.


e.g

straight after the opening body tag i have:

<div id="leftside">

</div>

then in my css style in head tags, i add a new style:

#leftside{background-color:#993333}

Then the whole white background on the whole screen is filled with that colour.

How can I separate the 3 main areas on the screen?

Thanks


 
hey

why dont you set the body color to a specified color:
body
{background-color:#FFFFFF}

Then the main div to:
#main{ width: /*whatever width*/;
margin: 0 auto ;
position: relative ;}

All the above will perfectly center your page and set a bacground color of the whole page.

after that simply insert 'background-color:#/*whatever color*/' into any <div> or <span> styles, in order to control their background color; unless you want it to be the same.

 
Do you want the same colour both on left and right side of the page? Then just apply background colour to body. If you want different ones apply one as a background colour and the other as the image.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top