...

View Full Version : center background image



jvignacio
11-15-2008, 11:59 AM
hi guys just wondering how i center a background image using css.

body{ background-image: url(gatecrasher.jpg); <-- once i apply my code, it displays the image tiled all over the background. i just want 1 huge image of the picture in the background. cheers

rangana
11-15-2008, 12:10 PM
background-image: url(gatecrasher.jpg) no-repeat center center;

jvignacio
11-15-2008, 12:16 PM
background-image: url(gatecrasher.jpg) no-repeat center center;



ahh didnt work. the whole background turned white!!


body{
background-image: url(Dj_Club_Dmx_Lighting.jpg)no-repeat center center;
margin-left: 15em;
margin-right: 15em;
color: white;
}

rangana
11-15-2008, 12:18 PM
My bad, please remove highlighted:


body{
background-image: url(Dj_Club_Dmx_Lighting.jpg)no-repeat center center;
margin-left: 15em;
margin-right: 15em;
color: white;
}

jvignacio
11-15-2008, 12:23 PM
My bad, please remove highlighted:


body{
background-image: url(Dj_Club_Dmx_Lighting.jpg)no-repeat center center;
margin-left: 15em;
margin-right: 15em;
color: white;
}



haha okay now that is just centered right in the middle. i need it to be the whole screen the 1 pic. sorry if i gave u the wrong info before. so basically need the pic to be stretched out in the whole page

Apostropartheid
11-16-2008, 12:39 AM
haha okay now that is just centered right in the middle. i need it to be the whole screen the 1 pic. sorry if i gave u the wrong info before. so basically need the pic to be stretched out in the whole page
That's really not a good idea. Doing this twists the image's aspect ratio and distorts it. You'd do much better leaving it on its own in the top left/whever and allowing the page to expand over it.

jvignacio
11-16-2008, 06:20 AM
That's really not a good idea. Doing this twists the image's aspect ratio and distorts it. You'd do much better leaving it on its own in the top left/whever and allowing the page to expand over it.

yea good idea, ill just leave it tiled in the background. Thanks!

Major Payne
11-16-2008, 08:15 AM
haha okay now that is just centered right in the middle. i need it to be the whole screen the 1 pic. sorry if i gave u the wrong info before. so basically need the pic to be stretched out in the whole pageSee http://www.cssplay.co.uk/layouts/background for how to fill a background image to full screen in CSS.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum