important > 内联 > ID > 类| 伪类| 属性选择 > 标签 | 伪元素 > 通配符 > 继承
例如
1、仅一个选择器单词的时候#id高于.class;
2、div#test2比#test2多了一个单词,那么多一个单词的优先级高;
3、同样多一个单词,但其中一个有#id选择,则#test3要高于div .test3;
4、.body #test4高于body #test4,同样多层级时,.class高于tag;
5、html #test5与body #test5有同样的优先级,先写的会被覆盖;
6、#body #test6高于.html #test6;
7、html #body #test7高于.html .body #test7;
8、#html.html .body #test8与.html #body.body #test8同级。
参考资料: css中选择器的优先级 http://www.studyofnet.com/news/1139.html
5万+

被折叠的 条评论
为什么被折叠?



