...

View Full Version : background colors



Christech4000
10-20-2007, 05:54 PM
I am trying to figure out the style declaration that will enable me to set background colors : left% / center% / right% , say i wanted the left to be #FFFFFF at 25%, the center #000000 at *, and right at 25%. does this make sense? i want to center my page on a black background with white on both sides, or any color combinations set to the positions I desire according to the needs of my pages layout.

Fang
10-20-2007, 06:44 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>layout</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<style type="text/css">
* {margin:0; padding:0;}
html {background:#fff; height:100%;}
body {background:#000; color:#fff; width:50%; height:100%; margin:auto;}
</style>

</head>
<body>
<p>Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius.</p>
</body>
</html>

srule_
10-20-2007, 06:55 PM
SINCE you are cenetring the content area, the best way to do it will be make a "contentwrap" div that will be centered, and set the padding/margins to 0. give the this contentwrap div wtv background color u want, and then give the body the other background color u want

VIPStephan
10-20-2007, 06:59 PM
SINCE you are cenetring the content area, the best way to do it will be make a "contentwrap" div that will be centered, and set the padding/margins to 0. give the this contentwrap div wtv background color u want, and then give the body the other background color u want

That's exactly how it works in Fang’s example. I guess it is in older browsers where the body element had only limited stylability but in current browsers you could actually scrap the wrapper div and use the body as such.
Also in XHTML you have to assign the general page background color to the html element since the body occupies only a part of the viewport.

srule_
10-20-2007, 07:14 PM
That's exactly how it works in Fang’s example. I guess it is in older browsers where the body element had only limited stylability but in current browsers you could actually scrap the wrapper div and use the body as such.
Also in XHTML you have to assign the general page background color to the html element since the body occupies only a part of the viewport.

I prefer to make a contentwrap div incase i want to ad a boarder to somthing to it later, also gives one more area to add background images ext...

Fang
10-20-2007, 07:40 PM
The example will work in all modern browsers and IE6 & IE7 in standards mode.
The canvas (http://msdn2.microsoft.com/en-us/library/bb250395.aspx#cssenhancements_topic4) was 'moved' from body to html in IE6, earlier IE browsers will not display the page as intended. As a consiquence of the change the infamous scrollbar colors must be set in html not body
Note that it is possible to have a background image in body and html



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum