View Full Version : How do you center a background image?


Sploosh
02-20-2004, 05:24 AM
My style sheet looks like this:

<style type="text/css">body {background:url(http://www.hamsterhouse.com/voosh/Shirou.bmp) no-repeat; fixed; background-color: #ffffff;}</style>

Now how do I make the background center?

salomeyasobko
02-20-2004, 05:26 AM
adding background-position:center should work :)

Sploosh
02-20-2004, 05:26 AM
Thank you!

salomeyasobko
02-20-2004, 05:29 AM
no problem

Sploosh
02-20-2004, 05:31 AM
Erm... Another problem now. ^^;; I can't get it to stay fixed, and not repeat at the same time.

pb&j
02-20-2004, 05:36 AM
change this...
fixed;

into this...
background-attachment: fixed;

Sploosh
02-20-2004, 05:38 AM
Hmm... Still not working. This is what I have now:

<style type="text/css">body {background:url(http://www.hamsterhouse.com/voosh/Shirou.bmp) background-attachment: fixed; background-color: #ffffff; background-position:center}</style>

salomeyasobko
02-20-2004, 05:40 AM
oh, i see your problem, change it to this:

<style type="text/css">body {background:url(http://www.hamsterhouse.com/voosh/Shirou.bmp); background-attachment: fixed; background-color: #ffffff; background-position:center}</style>

Sploosh
02-20-2004, 05:42 AM
The fixed part is working now, but it still repeats. Anymore ideas? (And thanks for the help! ^^)

salomeyasobko
02-20-2004, 05:46 AM
add background-repeat: no-repeat to the code. but make sure there is a ; thing before it this time :)

Sploosh
02-20-2004, 05:47 AM
I don't understand... I put background-repeat: no-repeat;

Right?

salomeyasobko
02-20-2004, 05:49 AM
here, just put:

<style type="text/css">body {background:url(http://www.hamsterhouse.com/voosh/Shirou.bmp); background-attachment: fixed; background-color: #ffffff; background-position:center; background-repeat: no-repeat; }</style>

Rosey
02-20-2004, 06:24 AM
if it still doesn't work, post your url where you are using the code.