Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the characteristics of the background attribute in css

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you what are the characteristics of the background attribute in css. I hope you will get something after reading this article. Let's discuss it together.

Abbreviated order: color-image-repeat-attachment-position

Eg:body {background:#ffffffurl ('img.png') no-repeatrighttop}

Let's introduce the characteristics of each attribute in order:

1. Background-color:red;#ffffff;rgb (255255255)

Three color representations, namely the color name, hexadecimal and RGB; can set the background color for all elements; the default is transparent.

2. Background-image:url ('img.jpg')

The image address can be a relative path or an absolute path; the default tile is displayed repeatedly

III. Background-repeat:repeat-x;repeat-y;no-repeat

Default tiling repeat display

IV. Background-attachment:scroll;fixed;local;inherit

Background-attachment means whether the background image is fixed or scrolled with the rest of the page; default scroll

Scroll means that the background picture scrolls along with the rest of the page; fixed is fixed; inherit inherits from the parent element; and local scrolls with the scrolling element.

5. Background-position:bottomcenter;top;66%33%;50px100px

There are four representations: one is the top,left,bottom,right,center combination, the second is a value, the system defaults to center; three is the percentage, and the fourth is to write pixels directly.

The latter two are of high accuracy.

6. Background-clip:border-box;padding-box;content-box; specifies the drawing area of the background map.

7. Background-origin:border-box;padding-box;content-box; specifies the location area of the background image.

Note: if the background image background-attachment is "fixed", this property has no effect.

8. Background-size:auto (default); length (two values, one wide and one high, the default second is auto); percentage (the assignment principle is the same as length); cover (the aspect ratio of the image is maintained and the image is scaled to the minimum size that will completely cover the background location area); contain (when the aspect ratio of the image is maintained and the image is scaled to the minimum size suitable for the background location area)

After reading this article, I believe you have a certain understanding of "what are the characteristics of background attributes in css". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report