< br>和:: after或:: before [英] <br> and ::after or ::before

查看:254
本文介绍了< br>和:: after或:: before的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用内容可编辑的HTML编辑器,我想用特殊字符(↩)表示换行符(< br> )每行的末尾以< br> 结尾。因此,我想为 content 添加一个伪元素 ::

I am writing a HTML-editor using content-editable and I wanted to indicate line breaks (<br>) with a special character ("↩") at the end of each line that ends with a <br>. Therefore I wanted to add a pseudo-element ::after with that character as content.

br::after { content: ' ↩'; }

很遗憾,这不起作用。 :: before 也不起作用。

Unfortunately this doesn't work. ::before doesn't work either.

是否还有可能达到所需的结果?

Is there another possibility to achieve the desired result?

推荐答案

从这个接受的答案:

From this accepted answer : Which elements support the ::before and ::after pseudo-elements?


您可以在这里阅读 http:// www。 w3.org/TR/CSS21/generate.html ::after
仅适用于具有(文档树)内容的元素。 < input>
没有内容,以及< img> < br>

As you can read here http://www.w3.org/TR/CSS21/generate.html, :after only works on elements that have a (document tree) content. <input> has no content, as well as <img> or <br>.

/ p>

Not funny, have you considered doing this with an image?

content: url(image.jpg)

这个说法,我设计的东西与:: before为悬浮在锚点上的背景叠加。

This saying, i was designing something with ::before for a background-overlay on hover on an anchor.

我HAD指定css内容为空{content =} otherwize不显示。

I HAD to specify css content to empty {content=""} otherwize not displaying.

这篇关于&lt; br&gt;和:: after或:: before的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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