Html 如何使用css的content属性添加html特殊字符(右箭头)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18186180/
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
How to add html special character (right-arrow) using content property of css?
提问by Jay Shukla
I am trying to add html special character using its code. Its working fine when I use it inside my div but how can I do this using css.
我正在尝试使用其代码添加 html 特殊字符。当我在我的 div 中使用它时它工作正常,但是我如何使用 css 来做到这一点。
I have tried as following.
我试过如下。
.right-arrow:after {
content:'►'
}
EDIT
编辑
What I wanted is not there in Matt Ball's answer because I wanted code for right arrow and in that question there is code for down arrow only. So its not duplicate.
我想要的不在 Matt Ball 的答案中,因为我想要右箭头的代码,而在那个问题中只有向下箭头的代码。所以它不是重复的。
回答by koningdavid
Special characters work a little bit different with pseudo-elements. You can't use HTML entities in CSS, but you can use Unicode hex escapes. Here is a tool to convert the numeric value of the special character to the CSS value.
特殊字符与伪元素的作用略有不同。您不能在 CSS 中使用 HTML 实体,但可以使用 Unicode 十六进制转义符。这是一个将特殊字符的数值转换为CSS值的工具。
http://www.evotech.net/articles/testjsentities.html
http://www.evotech.net/articles/testjsentities.html
for example ►
needs to be \25BA
例如►
需要是\25BA
working example:
工作示例:
.right-arrow:after {
content:'BA'
}