The background-position property in CSS accepts several types of values to specify the position of a background image. Here are the main options:
-
Keywords:
top,bottom,left,right,center- Example:
background-position: top left;
-
Length values:
- You can use units like
px,em,%, etc. - Example:
background-position: 50px 100px;
- You can use units like
-
Percentage values:
- Values can be specified as percentages of the element's dimensions.
- Example:
background-position: 50% 50%;(centers the image)
-
Multiple values:
- You can specify both horizontal and vertical positions.
- Example:
background-position: right 20px bottom 10px;
Example:
.element {
background-image: url('image.jpg');
background-position: center top; /* Centers horizontally, aligns to the top */
}
Feel free to ask if you need more details or examples!
