Reputation: 1667
How can I center a background using a CSS element?
Upvotes: 2
Views: 3607
Reputation: 654
background-position:center;
https://developer.mozilla.org/en/CSS/background-position
Upvotes: 10
Reputation: 784
You can also use percentages, so
background-position: 50% 0;
would centre the background horizontally. The beauty of percentages is they offers greater flexibility than keywords. You can position a background a quarter of the way across the screen with,
background-position: 25% 0;
and a quarter of the way across and 3 quarters of the way down with,
background-position: 25% 75%;
Upvotes: 5