惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

主题客

网站服务 - 主题客 Zane · WordPress 无边栏高级多功能商用主题 - 主题客 升级为 PHP 8.0+ 提示 PHP Deprecated 错误的解决办法 - 主题客 保护隐私信息,使用星号隐藏手机号码、邮箱和用户名 - 主题客 niRvana 关注微信公众号扫码登录扩展 - 主题客 Verdure 关注微信公众号扫码登录扩展 - 主题客 在线编辑图片WebP格式转换图片压缩小技巧 - 主题客 解决 WordPress 5.8+ 无法上传 webp 图片的问题 - 主题客 WordPress 5.8 禁用小工具区块编辑模式 - 主题客
CSS 伪元素 content 属性中文乱码的解决 - 主题客
主题客 · 12月7日 · 2022年 12月7日 · 2022年 · 2022-12-19 · via 主题客

最近在做主题维护的时候,偶然间发现在部分浏览器当中,用CSS伪元素的content属性显示文字时,用中文直接写的时候可能会出现下面这种乱码问题:

.cxcalendar:after {
    content: '年';
}

检查文件和CSS文件的编码格式,都是utf-8,编码是没有问题的。其实这也不算是什么新鲜问题了,都是一些在开发工作中需要注意的一些小问题。最好的解决办法是css中尽量不要出现中文,实在要用中文要转换成Unicode编码。

可以使用网上一些在线的 “中文转Unicode” 工具把中文转换一下就可以解决。

这里以中文 “年” 字为例,转换后得到Unicode编码 “\u5e74” ,这里要注意不能直接复制使用在CSS里。

根据上面的规则,我们应该把 “\u5e74” 中的 “u”去掉,即变成 “\5e74”,问题即可解决。

.cxcalendar:after {
    content: '\5e74';
}