How would I use a image size of 1008x576 as the background centered with black background color. Please could anyone help me with the CSS code for this.

2 answers

2
points
body {
    background: #000 (/images/your_image.png) 50% 0 no-repeat;
}
Answered about 7 years ago by Dwayne Anderson
  • And if you want it centered vertically as well... body { background: #000 (/images/your_image.png) 50% 50% no-repeat; } Doug about 7 years ago
0
points

You could also use the center keyword for centering in any axis. I''ve always found that a little more safe as some IE-version can misinterpret a percentage value if something else than 0%, 50% or 100% (http://www.sitepoint.com/blogs/2007/07/05/css-using-percentages-in-background-image/).

Answered about 7 years ago by Jens Hedqvist