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 distinguish CSS from the calculation method of priority weight in CSS2

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article is about how to distinguish CSS from priority calculation in CSS2. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Without saying much, let's take a look at it.

Recently, during the development project, there were some problems with the priority of CSS styles due to the application of a large number of CSS styles, so I went back to other people's articles and the calculation method of CSS priority weight on W3C. With regard to code testing, interested friends can write code separately according to the calculation method for testing. I will not write piles here, but simply identify the CSS from the priority weight calculation method.

The calculation in the W3C standard is that the selector of CSS is divided into four groups, that is, the abbreviation for each style of a b c d is CSS {a, the b is the Id selector, the c is the class element, the pseudo class and all other non-element objects d are elements.

The first principle for determining which style works is that the order of a > b > c > d comparison is from left to right. It can be understood that if a compares, except for the results, it can be understood that if a compares, it no longer compares b, for example, {0grad, 6, 3, 3, 3, 3, and 3}. In total, it is the first big, but the second is an inline style, so the second works. The first is invalid, and so on.

In addition, there are several rules, that is, under the same weight, the back covers the front, which can also be understood as the same attribute in the abbreviated statement of the same style. if you repeat it, then the latter will overwrite the previous definition. If there are students who do not understand or have different views, you are welcome to leave a message for discussion!

The above is how to distinguish the CSS from the priority calculation method in CSS2. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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