和::之后或::之前( and ::after or ::before)

编程入门 行业动态 更新时间:2024-10-26 16:22:37
和::之后或::之前( and ::after or ::before)

我正在编写一个使用内容编辑的HTML编辑器,并且我希望在每行以“ <br>结尾处指定带有特殊字符(“↩”)的换行符( <br> )。 因此我想添加一个伪元素::after作为content 。

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

不幸的是,这是行不通的。 ::before也不起作用。

是否有另一种可能性来达到预期的结果?

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: ' ↩'; }

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

Is there another possibility to achieve the desired result?

最满意答案

从这个公认的答案: 哪些元素支持:: before和:: after伪元素?

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

不好笑,你有没有考虑过这样做的图像?

content: url(image.jpg)

这个说法,我在之前用::设计了一个东西,用于悬停在锚点上的背景覆盖。

我必须指定css内容为空{content =“”} otherwize不显示。

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

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>.

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

content: url(image.jpg)

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

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

更多推荐

本文发布于:2023-04-29 08:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1335867.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!