View Full Version : centered background


Moonlit
07-08-2004, 04:19 AM
I'm making my web logo a background so that text can go over top part of it. Does a browser automatically center backgrounds so that the logo background will be centered, or do I have to specify...and if so, how might I do that?

lefty
07-08-2004, 04:26 AM
If you use css, you can center a background image this way:

<style type="text/css">
<!--
body {
background-image:url(image.jpg);
background-position:50% 50%;
background-repeat:no-repeat;
background-attribute:fixed; }
-->
</style>

I stuck some extra atrributes in there, but you can take them out if you don't need them.

Moonlit
07-08-2004, 04:42 AM
Is the "fixed" part what centers it?

kittycat
07-08-2004, 05:07 AM
background-position:50% 50%;
That part is what centres it

Chadstar
07-08-2004, 05:14 AM
the fixed part is so that when you scroll, the background image remains stationary and everything else on the page scrolls.



Hope this helps

Chadstar