有这样一个例子
<div class="div1">
<div class="div2">
Test
</div>
</div>
在进行选择时。我们来比较一下以下两种方法的优先级。
1. .div1 div{ font-size:12px}
2. .div2{font-size:22px}
之前一直错误的以为类名选择器会高于元素选择器,也就是第二种样式优先级更高。但是今天发现1的权重更高,类名权重为10,元素名权重为1的话,
1中样式的权重为11,大于2中样式为10的权重,自然加载的是第一种样式。