简体   繁体   English

CSS选择器中未知/无效的伪类如何处理?

[英]How are unknown/invalid pseudo-classes in CSS selectors handled?

What does this CSS selector should point to? 这个CSS选择器应该指向什么? AFAIK :bar pseudo-class does not exist... AFAIK:bar伪类不存在...

.Today_s_foo:bar
{
 font-size: 21px;
 font-family: "Ubuntu";
}

Per the current specification for parsing errors in selectors: "the entire rule in which the selector is used is dropped." 根据当前用于选择器中错误分析的规范 :“删除了使用选择器的整个规则。” See also this part of the spec for an example of the consequences. 有关后果的示例,另请参见规范的这一部分

By "rule" it means every property setting inside the {brackets} will be ignored if any part of the selector is parsed as invalid. “规则”意味着{brackets}每个属性设置都将被忽略,如果选择器的任何部分被解析为无效的话。

Normally it should invalidate the whole rule, which may be important when using multiple selectors in one rule, see simple example: http://jsfiddle.net/S56xM/ 通常,它会使整个规则无效,这在一条规则中使用多个选择器时可能很重要,请参见简单示例: http : //jsfiddle.net/S56xM/

HTML: HTML:

<div>Hello!</div>

CSS: CSS:

div, div:foobaresque { font-size: 100px; }

You will see that the div { font-size: 100px; } 您会看到div { font-size: 100px; } div { font-size: 100px; } "sub-rule" is not applied, even if our mind tells us it would be applied. div { font-size: 100px; }即使我们的思想告诉我们将应用“子规则”,也不会应用。

Correction applied 修正已应用

The rules in .Today_s_foo will not be set on any working browser. .Today_s_foo的规则不会在任何运行的浏览器上设置。

I thought it was listed as an Unrecommended hack on http://www.javascriptkit.com/dhtmltutors/csshacks3.shtml 我认为它在http://www.javascriptkit.com/dhtmltutors/csshacks3.shtml上被列为“不推荐的黑客”

IE IE

.Today_s_foo:IE6 /* IE6 hack */

but its not there. 但它不在那里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM