CSS“内容”属性中的HTML特殊字符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4476322/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML special characters in CSS "content" attribute
提问by sethvargo
I'm trying to add content to something before an item using the CSS :before + content: fields. I want to insert a checkmark (☑), BUT if I use that in the content option, it prints as the literal. How can I tell CSS to make that a checkmark, not the literal string ☑?
我正在尝试使用 CSS :before + content: 字段在项目之前添加内容。我想插入一个复选标记 (☑),但是如果我在内容选项中使用它,它会打印为文字。我如何告诉 CSS 将其设为复选标记,而不是文字字符串 ☑?
回答by Flack
Try this:
尝试这个:
#target:before {
content: "11";
}
回答by Brad Mace
You need to use Unicodevalues inside the content
property. (The list of miscellaneous symbolsmay also be useful.)
您需要在属性中使用Unicode值content
。(杂项符号列表也可能有用。)
A heavy checkmark is listed as U+2713
so you would put content: "\2713";
列出了一个沉重的复选标记,U+2713
所以你会放content: "\2713";
回答by Yi Jiang
Use the checkbox character literally in your CSS rule instead of the encoding -
在 CSS 规则中逐字使用复选框字符而不是编码 -
#target:before {
content: "?";
}