如何在CSS中转义单引号或双引号? [英] How can I escape single or double quotation marks in CSS?
本文介绍了如何在CSS中转义单引号或双引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下HTML代码:
I have the following HTML code:
<div id="working">Touch Me!</div>
<div id="notworking">Don't Touch Me!</div>
我有这个CSS:
#working:hover:after{
content: "Nice Touch";
color: #0C6;
}
#notworking:hover:after{
content: "I Said Don't Touch Me";
color: #C30;
}
此代码运行正常(我的示例如下):
http://jsfiddle.net/gchoken/NaEPq/
This code is working fine (my example is here): http://jsfiddle.net/gchoken/NaEPq/
我的问题是,当我使用双引号我说不要碰我
时,我收到警告。
My problem is that when I use double quotes for "I Said Don't Touch Me"
, I get a warning.
CSS:
#notworking:hover:after{
content: ""I Said Don't Touch Me"";
color: #C30;
}
警告讯息:
Warning: Found unclosed string '";'.
那么,我怎么才能在CSS中转义单引号或双引号?
So, how exactly can I escape single or double quotes in CSS?
推荐答案
使用反斜杠。 b
Use a backslash.
content:"i said don\"t Touch me";
单引号字符串中的单引号也是如此。
Same goes for single quotes within single-quoted strings.
这篇关于如何在CSS中转义单引号或双引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文