The Background-position property sets the starting position of the background image.
Grammar:
Background-position:length | | Length
background-position:position | | Position
Value:
Length: Percent | Length value consisting of floating-point numbers and unit identifiers
Position:top | Center | Bottom | Left | Center | Right
1, Background-position is not set, the default is background-position:0 0:
The effect background-position:left top; and background-position:0% 0%; it's consistent.
<! DOCTYPE html>
The picture is as follows:
2, Background-position set the specific value, the first value represents the x-axis movement, the second value represents the y-axis movement amount:
div{ width:400px; height:300px; Background:transparent URL (images/img5.jpg) no-repeat; border:5px solid Green; background-position:70px 40px;//picture moves to the right 70px, moving down 40px, If the picture to the left or up, you can set a negative value background-position : -70px-40px
}
:
3.background-position:center Center or background-position:50% 50%; Set Background Center
div{ width:400px; height:300px; Background:transparent URL (images/img5.jpg) no-repeat; border:5px solid Green; /*background-position:center center;*/ background-position:50% 50%; }
:
CSS Background-position Properties