我有一个动态加载的 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).
关于css - IE9 怪癖模式下 css ID 开头的下划线未注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6326544/