Background Position
suggest changeThe background-position property specifies the starting position of a background image or gradient.
.myClass {
background-image: url('path/to/image.jpg');
background-position: 50% 50%;
}
The position is set with an X and a Y coordinate. Each can use any CSS length or a percentage.
Unit | Description |
–– | ———– |value% value% | A percentage for the horizontal offset is relative to (width of background positioning area - width of background image).A percentage for the vertical offset is relative to *(height of background positioning area - height of background image)*The size of the image is the size given by background-size. |valuepx valuepx | Offsets background image by a length given in pixels relative to the top left of the background positioning area |
Units in CSS can be specified by different methods (see here).
Longhand Background Position Properties
In addition to the shorthand property above, one can also use the longhand background properties background-position-x and background-position-y. These allow you to control the x or y positions separately.
NOTE:
background-position-xandbackground-position-yare supported in current browsers, including Firefox 49 and later.