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

How to use the background property in CSS

2025-03-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to use the background attribute in CSS". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use the background attribute in CSS".

The background attribute is background-color,background-image,background-position,background-attachment,background-repeat, an acronym for these five attributes, which has the advantage of being easier to write than a single attribute and writing a lot less code. It is sometimes a bit confusing in the order in which these five attributes are written. The following code is taken from Sohu:

The code is as follows:

.bBot {background:url (.. / images20130624/bg.png) no-repeat-1424px-5px; overflow:hidden;}

.cBot {background:url (.. / images20130624/sohubg01.png) 0-181px repeat-x;width:758px;height:6px;clear:both;font-size:1px;margin:0 auto;}

The order of the background attribute of the .bBot selector is background-image,background-repeat,backgroundf-position. (background-repeat in front, backgroundf-position in the back)

The order of the background attribute of the .cBot selector is background-image,background-position,background-repeat. (background-position in front, background-repeat in the back)

That is, the CSS of the same company has a different style of writing, so I think it's a little wrong.

Let's take a look at the official definition of the background attribute of CSS:

Value: ['background-color' > |] | inherit

Initial: see individual properties

Applies to: all elements

Inherited: no

Percentages: allowed on' background-position'

Media: visual

Computed value: see individual properties

The content of the above table is just that the values of the defined background attribute contain those contents, but the order of these values is not specified (although this can be considered the recommended order, and if you do so, the code is more readable).

Thank you for your reading, these are the contents of "how to use the background attribute in CSS". After the study of this article, I believe you have a deeper understanding of how to use the background attribute in CSS, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Internet Technology

Wechat

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

12
Report