Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Nov 2008
    Posts
    23
    Thanks
    2
    Thanked 0 Times in 0 Posts

    center background image

    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

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Code:
    background-image: url(gatecrasher.jpg) no-repeat center center;
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #3
    New Coder
    Join Date
    Nov 2008
    Posts
    23
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rangana View Post
    Code:
    background-image: url(gatecrasher.jpg) no-repeat center center;

    ahh didnt work. the whole background turned white!!

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

  • #4
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    My bad, please remove highlighted:
    Code:
    body{
    background-image: url(Dj_Club_Dmx_Lighting.jpg)no-repeat center center;
    	margin-left: 15em;
    	margin-right: 15em;
    	color: white;	
    }
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #5
    New Coder
    Join Date
    Nov 2008
    Posts
    23
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rangana View Post
    My bad, please remove highlighted:
    Code:
    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

  • #6
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    Quote Originally Posted by jvignacio View Post
    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.

  • #7
    New Coder
    Join Date
    Nov 2008
    Posts
    23
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by CyanLight View Post
    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!

  • #8
    Regular Coder
    Join Date
    Aug 2005
    Location
    MS
    Posts
    829
    Thanks
    10
    Thanked 79 Times in 77 Posts
    Quote Originally Posted by jvignacio View Post
    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
    See http://www.cssplay.co.uk/layouts/background for how to fill a background image to full screen in CSS.
    ☠ ☠RON☠ ☠


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •