How can I center a background using a CSS element?
background-position:center;
https://developer.mozilla.org/en/CSS/background-position
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%;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With