<分区>
标签 css
<分区>
Possible Duplicate:
What characters are valid in CSS class names?
如果这应该是这样的话就不要这样做,但是当我指定一个类:.3plans 时,它不会应用样式。但是当我将类名更改为 .plans 时,它会识别样式。这是为什么?请注意,.3plans 类是唯一的,并且在我的工作表中没有其他类似的样式,因此它不能重复。这种现象是一种常见的 CSS 做法吗? (不要在样式中使用数字)
最佳答案
如果 class
& ID
是从数字开始的,则 css 无法识别。但是你可以这样写 .plans3
而不是 .3plans
。
根据 W3c
In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-z0-9] and ISO 10646 characters U+00A1 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, 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".
查看此讨论了解更多 Which characters are valid in CSS class names/selectors?
关于CSS 样式无法识别数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11100048/