优化 css 与 Google 页面速度让我很困惑
我正在使用谷歌页面速度,它告诉我我的CSS效率低下...
非常低效的规则(很好在任何页面上修复):
* table.fancy thead td Tag key with 2 descendant selectors and Class overly qualified with tag
* table.fancy tfoot td Tag key with 2 descendant selectors and Class overly qualified with tag
CSS规则是
table.fancy {border: 1px solid white; padding:5px}
table.fancy td {background:#656165}
table.fancy thead td, table.fancy tfoot td {background:#767276}
我希望页眉和页脚的背景颜色与正文不同table(数据表)
- 基于什么理由这是低效的?
- 如何让它更有效率?
为了谷歌的缘故,我不会向 thead 和 tfoot 添加类。
I'm using google page speed and it's telling me my css is inefficient...
Very inefficient rules (good to fix on any page):
* table.fancy thead td Tag key with 2 descendant selectors and Class overly qualified with tag
* table.fancy tfoot td Tag key with 2 descendant selectors and Class overly qualified with tag
The css rules are
table.fancy {border: 1px solid white; padding:5px}
table.fancy td {background:#656165}
table.fancy thead td, table.fancy tfoot td {background:#767276}
I want the header and footer in a different background color than the body of the table (a data table)
- On what grounds this is inefficient?
- How to make it more efficient?
I will not add a class to the thead and tfoot for googles's sake.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Google 的页面速度表明指定 2 个后代效率低下,这可能是真的,但我怀疑这不会对最终用户的体验产生任何影响。另一方面,有时你必须用这种方式来做你想做的事。其他时候,问题是让 CSS 更易于阅读和维护。
最终这是你的CSS,所以做你想做的。我认为微观优化并不重要。
另请参阅:此问题
Google's page speed says that specifying 2 descendants is inefficient, which may be true, but I doubt it'll make any difference on the end-user's experience. On the other hand, sometimes you have to use this way to do what you want. Other times, it's a matter of making the CSS easier to read and maintain.
Ultimately it's your CSS, so do what you want. I don't think that micro-optimization will matter.
See also: this question