Loading…
Everything will be ready in few seconds
- Theory
- Theory
- Comments
The background-position Property
The background-position
property controls the position of the background image. The property value consists of two parts separated by a space: x y
.
x
assigns the horizontal and y
the vertical position.
For the x
value, you can use the keywords left
, center
, right
, as well as percentage and pixel values.
For the y
value, you can use the keywords top
, center
, bottom
, as well as percentage and pixel values.
Here are some examples of how the property is used:
background-position: 50% 50%;
background-position: right bottom;
background-position: 50px 100px;
background-position: 0 100%;
background-position: left bottom;
This is what the examples look like in practice:
- The image will be centered;
- Bottom right corner;
- Padding of 50px from the left and 100px from the top;
- Bottom left corner;
- Bottom left corner.
- index.html
- style.css
Thanks! We’ll fix everything at once!
The code has changed, click “Refresh” or turn autorun on.
You’ve gone to a different page
Click inside the mini-browser to shift the focus onto this window.
Comments