且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

CSS:#id .class VS .class性能.哪个更好?

更新时间:2023-01-05 12:53:49

CSS选择器是因此,.videoContainer应该比#dialog .videoContainer更快",因为它错过了对#dialog的测试.

Therefore, .videoContainer should be "faster" than #dialog .videoContainer because it misses out testing for #dialog.

但是,这些充其量都是无关紧要的-您永远不会注意到它们之间的区别.对于正常大小的页面,我们谈论的时间太少了,甚至根本不存在.

However, this is all irrelevant at best - you'll never notice the difference. For normally sized pages, the amount of time we're talking about is so insignificant as to be nonexistent.

以下是专家的相关答案,您应该阅读:为什么浏览器从右到左匹配CSS选择器?

Here's a relevant answer by an expert that you should read: Why do browsers match CSS selectors from right to left?