Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $YECBGYFECGEAFWHA as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2

Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $BBWFDDBHHYHDXXAB as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2
关于css中的类名问题的介绍_创想鸟

关于css中的类名问题的介绍

关于css中的类名问题的介绍

以下以数字开头的 css 类名不会生效:

.1st{    color: red;}

一个合法的 CSS 类名必需以下面其中之一作为开头:

1、下划线 _

2、短横线 –

3、字母 a – z

立即学习“前端免费学习笔记(深入)”;

然后紧跟其他 _ , – 数字或字母。

(推荐教程:CSS入门教程)

用正则表示,一个合法的 CSS 类名为:

-?[_a-zA-Z]+[_a-zA-Z0-9-]*

根据CSS 标准中的描述,如果类名开头是短横线 – ,第二个字符必需是下划线 _ 或字母,但实测发现,除了提及的两个,紧跟另一个短横线也是生效的。

以下是测试代码及结果:

should apply red color

should apply red color

should apply red color

should apply red color

should apply red color

should apply red color

.1st { color: red;}.-1foo { color: red;}.-_foo { color: red;}.--foo { color: red;}.-foo { color: red;}.foo { color: red;}

结果如图:

22cee288b22a4a04c78897c896fc980.png

推荐视频教程:css视频教程

以上就是关于css中的类名问题的介绍的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1615045.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
css如何实现网页背景动态渐变效果
上一篇 2025年12月24日 04:42:36
css中的content属性该如何使用
下一篇 2025年12月24日 04:42:44

相关推荐

发表回复

登录后才能评论
关注微信