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

推荐订阅源

V
Vulnerabilities – Threatpost
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
WordPress大学
WordPress大学
Apple Machine Learning Research
Apple Machine Learning Research
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
P
Palo Alto Networks Blog
大猫的无限游戏
大猫的无限游戏
量子位
S
Secure Thoughts
博客园 - 【当耐特】
V
Visual Studio Blog
腾讯CDC
爱范儿
爱范儿
Webroot Blog
Webroot Blog
The Register - Security
The Register - Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Latest news
Latest news
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Cloudbric
Cloudbric
T
Troy Hunt's Blog
S
Security @ Cisco Blogs
B
Blog RSS Feed
I
Intezer
S
SegmentFault 最新的问题
N
News and Events Feed by Topic
云风的 BLOG
云风的 BLOG
C
CXSECURITY Database RSS Feed - CXSecurity.com
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
TaoSecurity Blog
TaoSecurity Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Schneier on Security
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Recorded Future
Recorded Future
Google DeepMind News
Google DeepMind News
Forbes - Security
Forbes - Security
雷峰网
雷峰网
博客园 - 司徒正美
C
Cisco Blogs
S
Securelist
L
LINUX DO - 最新话题
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
J
Java Code Geeks
N
News | PayPal Newsroom
N
News and Events Feed by Topic

主题客

网站服务 - 主题客 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';
}