...

View Full Version : CSS Background Center



whatg
01-05-2010, 10:18 PM
Hi guys, I'm new to this whole world of CSS and web design and was wondering if anyone could help me? I'm trying to center my background image but it doesn't seem to be in line with my header image that is centered, it goes slightly left of it. My background is the same width as my header so I don't know what is going on!

The page is here:http://grahamethomson.com/About_me.html

And the linking css is here:http://grahamethomson.com/design.css
http://grahamethomson.com/Background.css



Thanks for any help. :)

Excavator
01-06-2010, 01:13 AM
Hello whatg,
Those links are dead.

CoffeeCup.com
01-07-2010, 03:31 PM
Hello,

Please visit the following sites to see if they can help you out:

http://www.wpdfd.com/issues/70/css_from_the_ground_up/
http://www.csszengarden.com/
http://www.alistapart.com/topics/design
http://www.w3schools.com/css/default.asp

Hope this helps!!!
CoffeeCup.com :thumbsup:

boogily
01-07-2010, 03:34 PM
I think the css file is

http://grahamethomson.com/auto.css

Excavator
01-07-2010, 04:33 PM
Goodmorning whatg,
There is something odd about your DocType.
To center an element we need 3 things:

a DocType declaration
an element with a width
that elements right/left margins set to auto

Your code has those 3 things, but still doesn't work until I changed the DocType. You also have an error in the line that links your CSS file.
Make the top of your markup look like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Center test - no &quot;text-align: center&quot; set for body</title>
<link rel="text/css" href='auto.css' />

whatg
01-08-2010, 12:56 PM
Thanks for the help guys, managed to solve the problem. Needed to set the width. Am new to all of this but getting there.
:thumbsup:

Thanks again!

Excavator
01-08-2010, 04:25 PM
Goodmorning whatg,
Glad you got it fixed! The online version has not been updated so we can't see it in action yet.

That validator mentioned in my sig below can help find mistakes like this -
body{
baclground color:black;
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum