我正在编写一个使用内容编辑的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.
更多推荐
发布评论