是元素特定的CSS选择器坏吗? [英] Is element-specific CSS selector bad?
本文介绍了是元素特定的CSS选择器坏吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
p.error
好于或低于 .error
?
我读过元素特定的选择器是坏的,应该只使用,只有真正需要但没有人似乎知道为什么。我的意思是我明白, .error
更好的代码重用,但有某些特定的原因,我不应该解决类元素总是?
I have read that element-specific selectors are bad and should be used only if really needed but noone seems to know why. I mean I do understand that .error
is better for code reuse, but is there somekinda specific reason why I shouldn't address class with element always?
推荐答案
.error
比 p.error
。
要了解为什么这样更有效,我建议您阅读本文在css技巧。
To understand why this is more efficient I recommend you read this article over at css tricks.
这篇关于是元素特定的CSS选择器坏吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文