In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shares with you the content of a sample analysis of CSS selector weights. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The code is as follows:
Div.ui_infor p {font-size: 16px;}
.UI _ infor p {font-size: 14px;}
The code is as follows:
Test of css
For the above example, the final result is font-size: 16px, not the following font-size: 14px
This combined selector has a quick way to judge:
0,0,0,0
The first numeric value represents the style written on the label, such as
The code is as follows:
The second digit represents an id selector, such as # demo {}
The third digit is the representative: class name (.demo {}) or pseudo class (: hover) or attribute selector [rel= "xx"]
The fourth digit represents: tag selector p {}
Now use the first example to practice:
The code is as follows:
Div.ui_infor p {font-size: 16px;}
Its weight is: 0pm 0pm 1pm 2
The code is as follows:
.UI _ infor p {font-size: 14px;}
Its weight is: 0pm 0pm 1pm 1
Result: 0B0JOJE1JEI 2 > 0B0J0JE1JEI, so font-size: 16px is displayed.
Add:! The important weight is the highest, so there is no need to judge, but click BUG in the IE-6 browser.
Example:
The code is as follows:
P {font-size: 18px! important;font-size: 12px;}
In the IE-6 browser, it displays font-size: 12px, and some materials on the Internet say that IE-6 does not support! important, in fact, it is not right.
Let's take a look at the example:
The code is as follows:
P {font-size: 18px! important;}
P {font-size: 12px;}
In IE-6, font-size: 18px is displayed, which shows that IE-6 supports! important, but the performance is a little weird, the weird place is: written in the peer's style of the same name! the attribute of important is overridden by the following
For example, p {font-size: 18px! important;font-size: 12px;}, font-size: 12px overrides font-size: 18px! important.
With this weirdness, you can implement "min-height" in IE-6 without using CSS_hack.
The code is as follows:
P {min-height: 50pxbot heightfulauto! important;height:50px;}
Thank you for reading! This is the end of this article on "sample analysis of CSS selector weight". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.