How to set background property in CSS
This article mainly shows you "how to set background properties in CSS". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to set background properties in CSS".
The main background-related attributes are:
Background-color background Color
Background-image background picture
Whether background-repeat tiles repeat (default tile) | repeat-x (horizontal tile) | repeat-y (vertical tile) | no-repeat (no tile)
Background-position background position length (percentage) | position (topcenterbuttonleftright) is generally used together. If one direction is specified and the other direction defaults to center, the two methods can also be mixed up. Orientation nouns are not sequentially distinguished, but percentages are used sequentially all the time, first horizontally and then vertically.
Background-attachment background fixed or scrolling scroll | fixed
Background: whether the background color background picture is tiled, the background is fixed or the scrolling background position
# p1 {
Width:300px
Height:300px
Background-color:blue;/* defaults to transparent transparent * /
/ * background-color:transparent;*/
Background-image:url (Images/2.jpg)
Background-repeat:no-repeat;/* is not tiled. The default is horizontal and vertical tiling * /
/ * background-repeat:repeat-y;*/
/ * background-repeat:repeat-x;*/
/ * background-position:rightbottom;*/
Background-position:10%center
Background-attachment:fixed
}
If you want the background to be translucent and use rgba when specifying a color, an indicates transparency.
P {
Width:100%
Height:300px
Background-color:rgba (0. 0. 0. 6)
}
Use background to specify multiple url when you want to use multiple background images. Each group is separated by a', 'comma. If there is an overlap, the previous one overrides the last one, but the overall background color must be specified after the last url.
P {
Width:100%
Height:300px
Background:url (Images/2.jpg) no-repeatlefttop,url (Images/3.jpg) no-repeatrightbottomblue
}
The above is all the content of the article "how to set background properties in CSS". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!