Forum Moderators: not2easy

Message Too Old, No Replies

body and background colors

when body is smaler than page

         

santapaws

9:43 am on Feb 2, 2009 (gmt 0)

10+ Year Member



im not sure if there is a simple way to do this but where a site has the body color as white in an external css sheet and the width set to a maximum is there a simple way to set a different color for the area of the page outside that maximum width?

simonuk

9:50 am on Feb 2, 2009 (gmt 0)

10+ Year Member



I'm not sure your question makes 100% sense but here goes :-)

You could be seeing a gap around the body caused by the padding or margin. If that is the case then do:

body {padding:0;margin:0;background-color:white;}

That would eliminate the spacing on the body by pushing the body right up against the page.

If this isn't what you meant then what I would do is leave the body alone and add a container which would be smaller than the body:

body {padding:0;margin:0;background-color:white;}
#container {width:90%;}

Now put all your content inside the container and you can then style the position of the container to whatever you wish.

BeeDeeDubbleU

9:51 am on Feb 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Why would you want to do that when the area outside the maximum width cannot be seen?

santapaws

10:06 am on Feb 2, 2009 (gmt 0)

10+ Year Member



right i wanted to avoid having to make any site wide page changes albeit a tiny bit of code. I would have to add a container to every page. I always hate waiting for googles reaction to site changes. Sounds paranoid i know but experience has made me wary.

Heres the scenario. The universal style sheet has body max-width 1000px. The body is white so open the site up on a 1920 screen and the page looks horrible as it blends with the white of the screen in the broswer outside the max width area of the body. I would like to set the outside area to a different color rather than the body to counter this.

swa66

10:15 am on Feb 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Technicaly html is the parent of body and can have a different background color than body. In most browsers this is actually rendered properly if you decrease the size of the body element. But many browsers (and IE6 most of all) threat html and body a bit "special", so be sure to get what you want in all browsers you care about.

santapaws

10:31 am on Feb 2, 2009 (gmt 0)

10+ Year Member



thanks. Setting html separately is quite useful and a possible solution for most people (firefox 3, IE7).