使用CSS内容添加HTML实体 [英] Adding HTML entities using CSS content

查看:171
本文介绍了使用CSS内容添加HTML实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用CSS content 属性来添加html实体?

How do you use the CSS content property to add html entities?

我有一些链接

<div class="breadcrumbs">
    <a>One</a>
    <a>Two</a>
    <a>Three</a>
</div>

其中应用了以下样式:

.breadcrumbs a:before {
    content: '> ';
}

问题是当breadcrumb列表变长并且换行到下一行,箭头保留在前一行。显而易见的解决方案是将空间改变为不间断的空间,但这不起作用:

The problem is that when the breadcrumb list gets long and wraps to the next line, the arrow is left on the preceding line. The obvious solution is to change the space into a non-breaking space, but this doesn't work:

.breadcrumbs a:before {
    content: '>&nbsp;';
}

它实际上输出& nbsp; 到屏幕上。我通过粘贴字符直接粘贴其他奇怪的字符(如»),但是如何粘贴& nbsp;

It actually outputs &nbsp; onto the screen. I've got around this with other strange characters (like ») by pasting the character in directly, but how do you paste a &nbsp; ?

推荐答案

您必须使用转义的unicode:

You have to use the escaped unicode :

Like

.breadcrumbs a:before {
    content: '>\0000a0';
}

更多信息: http://www.evotech.net/blog/2007/04/named-html-entities -in-numeric-order /

这篇关于使用CSS内容添加HTML实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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