重要的类声明和优先级 [英] Multiple !important class declarations and precedence
本文介绍了重要的类声明和优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从理论上讲,如果您有这种情况:
Theoretically speaking, if you had this scenario:
<style type="text/css">
.class1 {
color:#F00 !important;
}
.class2 {
color:#00F !important;
}
</style>
<p class="class2 class1">Test</p>
哪种颜色应该优先?在这种情况下,浏览器如何确定优先级?
Which color should take precedence? How do browsers determine precedence in this scenario?
推荐答案
根据此来源:http://www.boogiejack.com/CSS_4.html
class2应该覆盖class1样式。
class2 should override the class1 styling.
规范顺序:作为最后一个
度假村,当所有其他冲突
解决规范不能
确定哪样式应该采用
优先级,指定的最后一个样式
将是所使用的样式。
Order of Specification: As a last resort, when all other conflict resolution specifications cannot determine which style should take precedence, the last style specified will be the style used.
这篇关于重要的类声明和优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文