23
In CSS, a ruleset is one of the basic building blocks that make up a stylesheet:
在CSS中,规则集是构成样式表的基本构建块之一:
.example {
font-size: 1.25rem;
color: red;
}
An empty ruleset is one that doesn't have any property declarations, just a selector:
空规则集是没有任何属性声明的规则集,只是一个选择器:
#id {
}
As you note, these rules don't have any effect on the rendering of a document, but some browsers will consume them when evaluating CSS only to find nothing there. Performance junkies detest any unnecessary overhead of this sort, so it's better to scrub them for the sake of cleanliness. In fact, CSS Lint has a rule specifically against empty rulesets, and Code is simply linting your CSS on-the-fly with the same set of rules.
正如您所注意到的,这些规则对文档的呈现没有任何影响,但是某些浏览器在评估CSS时会消耗它们而只是在那里找不到任何内容。表演爱好者厌恶这种不必要的开销,所以最好为了清洁而擦洗它们。事实上,CSS Lint有一个专门针对空规则集的规则,而Code只是简单地使用相同的规则集来快速地使用CSS。
However, empty rulesets can be useful in working around certain browser bugs such as this one. In such situations, removing the empty ruleset actually has adverse effects on page rendering, so they should be left there, ideally with a comment documenting their purpose.
但是,空规则集可用于解决某些浏览器错误,例如此错误。在这种情况下,删除空规则集实际上会对页面呈现产生负面影响,因此应将它们留在那里,最好留下记录其目的的注释。
You can disable linting by setting css.validate to false in your settings.json file. See the documentation for how to do this.
您可以通过在settings.json文件中将css.validate设置为false来禁用linting。请参阅文档以了解如何执行此操作。