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"; }   

相关文章