我有以下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中转义单引号或双引号?
答案 0 :(得分:13)
答案 1 :(得分:3)
只需使用\
即可转义"
#notworking:hover:after{
content:"i said don\"t Touch me";
color: #C30;
}