有人可以解释一下为什么在这个例子中第一条规则不是第二条规则吗?根据我的CSS特异性知识,第二个更具体,应该使用.但所有浏览器首先使用.
table.data .negative {
/* css specificity: 0,0,2,1 */
color: red;
}
table.data tr.inactive td {
/* css specificity: 0,0,2,3 */
color: gray; /* this should be used */
}
Run Code Online (Sandbox Code Playgroud)
<table class="data">
<tr class="inactive">
<td><span class="negative">should be gray</span></td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)