CSS:在对内容中的字符进行编码之后

CSS:after encoding characters in content(CSS:在对内容中的字符进行编码之后)

本文介绍了CSS:在对内容中的字符进行编码之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下 CSS,它似乎可以正常工作:

I am using the following CSS, which seems to be working:

a.up:after{content: " ↓";}
a.down:after{content: " ↑";}    

然而,这些字符似乎不能像这样编码,因为输出是文字并显示了实际的字符串:

The characters however cannot seem to be encoded like this, as the output is literal and shows the actual string:

a.up:after{content: " ↓";}
a.down:after{content: " ↑";}   

如果我不能对其进行编码,我觉得我应该在 jQuery 中使用诸如 .append() 之类的东西,因为它支持编码.有什么想法吗?

If I can't encode it, it feels like I should use something such as .append() in jQuery, as that supports the encoding. Any ideas?

推荐答案

要在 content 中使用编码的 Unicode 字符,您需要提供字符本身(如您所做的那样)或它们的 UTF-8转义序列而不是 HTML 实体:

To use encoded Unicode characters in content you need to provide either the characters themselves (as you do), or their UTF-8 escape sequences instead of HTML entities:

a.up:after { content: " 2193"; }
a.down:after { content: " 2191"; }   

这篇关于CSS:在对内容中的字符进行编码之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:CSS:在对内容中的字符进行编码之后

基础教程推荐