我有一个动态加载的CSS文件,其中包含一个带有ID的css行,如下所示:
#__my_css_id{
width: 100%;
height: 100%;
left: 0px;
top: 0px;
position: fixed;
background-color: #202020;
}
我不能改变这个页面以怪癖模式呈现的事实,因为它是一个远程托管的脚本(我的脚本).有些页面是怪癖,有些则不是.
当处于怪癖模式和IE9(没有尝试其他IE版本)时,css似乎没有正确加载或根本没有.事实上,如果我使用IE调试器(F12)调试css,那么我会看到所有的CSS,但是如果它们以这样的两个下划线开头,那么所有css IDS都会说UNKNOWN #__
如果我调试元素并检查css,那里没有任何css规则.怪癖模式是否在css ID的开头不允许下划线?
谢谢!
最佳答案 双下划线在CSS2中有效,但
quirks mode是CSS1的部分实现.
CSS2 spec说:
In CSS2, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, two hyphens, or a hyphen followed by a digit. Identifiers can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). For instance, the identifier “B&W?” may be written as “B\&W\?” or “B\26 W\3F”.
虽然下划线是CSS1中的无效字符:
In CSS1, selectors (element names, classes and IDs) can contain only the characters A-Z, 0-9, and Unicode characters 161-255, plus dash (-); they cannot start with a dash or a digit; they can also contain escaped characters and any Unicode character as a numeric code (see next item).