-4

So, I have a big image with logotype in the center, and thing that I asking for is how do I horizontally center the image, if screen width changes or varies between different devices?

I saw few solutions using "img" tag, but I need to know how to center background specifically.

body
{
  background-image: url('website-bg.jpg');
  background-repeat: no-repeat;
  background-size: cover;
}

It's OK on big screen, but I am not sure that my screen big enough to display website with various resolutions.

j08691
  • 204,283
  • 31
  • 260
  • 272
Yu Alypse
  • 1
  • 3

2 Answers2

0

You can use the background-position property, and set it to "center":

background-position: center;

K.G.
  • 59
  • 5
0

Background Position Center will center your background image.

background-position: center;

body
{
  background-image: url('website-bg.jpg');
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
}
Gamers Agenda
  • 433
  • 2
  • 13