Recently, many CSS codes have been used in projects! Important overwrites the original high-priority style. Generally, the more flexible things you need to do, the more work you need. So I think it is like! Important is a flexible and convenient rule. If it is used more often, it will definitely affect the performance. Based on this consideration, we wanted to remove all these styles by raising their priorities. But later I thought about it, I 'd like to google it. I guess it is generally unreliable. So I found this article Is! Important bad for performance ?. Below is the general meaning:
The CSS Parsing Code of firefox/Source/layout/style/nsCSSDataBlock. cpp #562 the important processing is as follows:
if (aIsImportant) { if (!HasImportantBit(aPropID)) changed = PR_TRUE; SetImportantBit(aPropID); } else { // ...
Source/layout/style/nsCSSDataBlock. h #219 The following comments describe the above Code:
/** * Transfer the state for |aPropID| (which may be a shorthand) * from |aFromBlock| to this block. The property being transferred * is !important if |aIsImportant| is true, and should replace an * existing !important property regardless of its own importance * if |aOverrideImportant| is true. * * ... */
As you can see above, firefox is! The important rule is easy to judge: it will include! The important style directly overwrites the normally generated style rules, and if it is resolved to the back, there will be! When the impant ant rule is used, the priority is compared with that of the previous impant ant rule. That is to say, use! The CSS rules of important are set to the highest priority, and then the pattern to be applied is determined in the highest priority.
The conclusion is: use! Important has no negative impact on performance. However, this rule is rarely used in terms of maintainability. However, this rule is not fully supported by IE6 bug (IE6 IE7 (Q) IE8 (Q! Impant ant rules.
References:
Https://developer.mozilla.org/zh-CN/docs/Web/CSS/Specificity
Http://www.w3cplus.com/css/the-important-css-declaration-how-and-when-to-use-it.html
Http://www.w3.org/TR/CSS2/cascade.html#important-rules
Http://w3help.org/zh-cn/causes/RA8003
Http://stackoverflow.com/questions/13743671/is-important-bad-for-performance
Http://www.html5rocks.com/zh/tutorials/internals/howbrowserswork/