首页 相关文章 CSS选择器的优先级

CSS选择器的优先级

  关于CSS选择器优先级,目前国内已有很多人进行过解释,但感觉不如人意,特别对于初学者,更是难以理解。这里我把W3C上所描述的规范以我的理解再解释一下,希望能给大家提供到帮助。

  在Calculating a selector’s specificity上的原文摘选如下:

A selector’s specificity is calculated as follows:

count 1 if the declaration is from is a ’style’ attribute rather than a rule with a selector, 0 otherwise (= a) (In HTML, values of an element’s “style” attribute are style sheet rules. These rules have no selectors, so a=1, b=0, c=0, and d=0.)
count the number of ID attributes in the selector (= b)
count the number of other attr...[ 查看全文 ]

2016-02-19 标签:

CSS选择器的优先级的相关文章

手机页面
收藏网站 回到头部