微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我可以在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类仅在情况下不同的名称

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Css3如何实现鼠标移上变长特效?(图文+视频)
css3怎么实现鼠标悬停图片时缓慢变大效果?(图文+视频)
jquery如何实现点击网页回到顶部效果?(图文+视频)
css3边框阴影效果怎么做?(图文+视频)
css怎么实现圆角边框和圆形效果?(图文+视频教程)
Css3如何实现旋转移动动画特效
js如何实现文字闪烁特效?(图文+视频)
CSS3怎么实现背景颜色渐变?(图文+视频)
Css3如何实现文本溢出隐藏并显示省略号效果
添加CSS的三种方式