我如何在CSS中转义单引号或双引号?
我有以下HTML代码:
<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/
我的问题是,当我为"I Said Don't Touch Me"
使用双引号时,我收到警告。
CSS:
#notworking:hover:after{
content: ""I Said Don't Touch Me"";
color: #C30;
}
警告信息:
Warning: Found unclosed string '";'.
那么,我该如何在CSS中转义单引号或双引号?
使用反斜杠。
content:"i said don"t Touch me";
单引号字符串中的单引号也一样。
jsFiddle演示
只需使用来逃避
"
#notworking:hover:after{
content:"i said don"t Touch me";
color: #C30;
}
演示@ http://jsfiddle.net/NaEPq/4/
链接地址: http://www.djcxy.com/p/88373.html上一篇: How can I escape single or double quotation marks in CSS?