0

我正在使用谷歌页面速度,它告诉我我的 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}

我希望页眉和页脚的背景颜色与表的主体(数据表)不同

  • 这是因为什么原因是低效的?
  • 如何让它更有效率?

为了谷歌的缘故,我不会在 thead 和 tfoot 中添加一个类。

4

1 回答 1

2

谷歌的页面速度说指定 2 个后代效率低下,这可能是真的,但我怀疑它会对最终用户的体验产生任何影响。另一方面,有时您必须使用这种方式来做您想做的事情。其他时候,这是使 CSS 更易于阅读和维护的问题。

最终它是你的 CSS,所以做你想做的。我认为微优化并不重要。

另见:这个问题

于 2010-04-10T07:16:16.763 回答