CSS background-position background image position
CSS background-position is used to define the position of the background image. It is one of the attributes of CSS background . It is often designed with background-image and background-repeat , so that the background image of the webpage is displayed on the top, bottom, left, right or even center. When you need to use the horizontal and vertical positions, you can give numbers, percentages, or orientation parameters to make the picture appear in the correct position. background-position is a standard CSS background position design method. All major browsers support background-position. .
CSS background-position basic syntax
Direction parameters that can be used
direction | parameter |
horizontal direction | left-align left, center-align center, right-align right |
Vertical direction | top-top alignment, center-center alignment, bottom-bottom alignment |
CSS background-position example 1. Various alignments
background-position: 30px 60px; // position 30px to the left and 60 px above
background-position: 10% 50%; // position 10% to the left and top 50 % Position
background-position: 10%; // The effect is the same as the previous line, 10% to the left and 50% to the top
CSS background-position example two, vertical center alignment
background-image:url('background image'); //First give the path or URL of the image you want to put in the background
background-repeat:no-repeat; //Do not display the background image repeatedly (display only once)
background-attachment:fixed; //The position of the background image is fixed
background-position:center; //The horizontal and vertical positions of the background image are aligned to the center
}
Post a Comment
0 Comments