visual studio不能使用html的css样式表,Visual Studio代码CSS错误“不要使用空规则集”...

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。请参阅文档以了解如何执行此操作。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值