CSS align background image center

Posted 20 April, 2009 in Other Stuff

If you want to center and middle align a background image, use the following CSS code:

body {
 background: #000 url(images/background.jpg) no-repeat center;
}

If you want a fixed image, center aligned but not middle aligned, try this:

body {
 background-image: url(images/background.jpg);
 background-repeat: no-repeat;
 background-attachment:fixed;
 background-position: 50% 0%;
}

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Twitter
  • Yahoo! Buzz

Your comment: