如何包括HTML编码的“content:”。 CSS中的字符? [英] How can I include a HTML-encoded "content:" character in CSS?

查看:148
本文介绍了如何包括HTML编码的“content:”。 CSS中的字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

使用CSS内容添加HTML实体

以下设置

CSS:

.header:before {
    content: "«";
}

.header:after {
    content: "»";
}

HTML:

<h3 class="header">Hello, this is some text which should be wrapped.</h3>

我只是喜欢在标题中写入的任何内容, (& laquo; )和» (& raquo; )。我如何使这项工作在CSS?目前显示为:

I'd simply like whatever is written in header to be wrapped in « (&laquo;) and » (&raquo;). How can I make this work in the CSS? It's currently appearing as:


& laquo;你好,这是一些应该包装的文本。 & raquo;

&laquo; Hello, this is some text which should be wrapped. &raquo;

而不是:


«你好,这是一些应该包装的文本。 »

« Hello, this is some text which should be wrapped. »


推荐答案

您不能在CSS中使用HTML实体,十六进制转义,例如

You can't use HTML entities in CSS, but you can use Unicode hex escapes, such as

span.url:before { content: "\27e8" }
span.url:after { content: "\27e9" }

(来自我自己的样式表之一你想要自己的确切字符的十六进制码点)。注意,与一些其他符号不同的是,十六进制数字直接跟在反斜杠后面,而不插入 u

(from one of my own stylesheets -- look up the hex codepoints for the exact characters you want yourself). Notice that unlike in some other notations, hex digits follow the backslash directly, with no intervening u.

这篇关于如何包括HTML编码的“content:”。 CSS中的字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆