我可以在CSS类名中使用camel-case

我想命名一个CSS类,并将其称为imgSuper。我可以在CSS类中使用camel-casing吗?

解决方法

从技术上来说,它是有风险的,因为CSS语法大多不区分大小写,在某些特定条件下的浏览器中,类名被视为区分大小写,因为规范没有规定浏览器在将CSS规则与HTML类匹配时应该如何处理名字

the specsection 4.1.3

All CSS Syntax is case-insensitive within the ASCII range…

In CSS,identifiers (including element names,classes,and IDs in selectors) can contain only the characters [a-zA-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”.

…the case-sensitivity of values of the HTML attributes “id” and “class”,of font names,and of URIs lies outside the scope of this specification.

而不是学习浏览器和情况敏感的条件,最好只是意识到最好的方法是最兼容的:在给定的CSS类的所有代码中使用相同的情况,不要创建两个或更多的CSS类仅在情况下不同的名称

相关文章

Css3如何实现鼠标移上变长特效?(图文+视频)
css3怎么实现鼠标悬停图片时缓慢变大效果?(图文+视频)
jquery如何实现点击网页回到顶部效果?(图文+视频)
css3边框阴影效果怎么做?(图文+视频)
css怎么实现圆角边框和圆形效果?(图文+视频教程)
Css3如何实现旋转移动动画特效