Center Background Image Using CSS – One Line of Code

Here is a little snippet of CSS code that you can use to center a background image. The background image will be fixed in its center position even if you scroll up or down the page.

Place this CSS code in the HEAD section of your HTML code

 



 

Don’t forget to change background.jpg to the name of your background image file.

Download: Example Page example_center_background_css.zip