CSS 样式无法识别数字

标签 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/

上一篇:jquery - 删除 img 的父标签并仍然保留 img

下一篇:Jquery 非选择器难度

相关文章:

javascript - 如何设置响应式 SVG 宽度?

javascript - 如何立即加载深色主题

JavaScript - "Scroll Down"按钮 - 从着陆页滚动到页眉顶部

css - 居中图像并将另一个图像向右浮动

jquery - 我正在尝试能够拍摄上传的图片并将其设为背景图片

javascript - jQuery - 使用变量更改背景图像?

javascript - 如何使用 jQuery 对 HTML 元素应用 css 转换?

css - 如何使用伪元素在悬停时突出显示段落

css - django 和 twitter bootstrap 在 IE8 中不能正常工作

jquery - 使用 jQuery 在单击时交换 CSS 背景图像