如何在元素之前使用CSS插入换行符 [英] How to insert a line break before an element using CSS
本文介绍了如何在元素之前使用CSS插入换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我觉得我看到了一种方法,使用CSS内容属性,在元素之前插入换行符。显然这不起作用:
I feel like I saw a way, using the CSS content property, to insert a line break tag before an element. Obviously this doesn't work:
#restart:before { content: '<br/>'; }
但是你怎么做呢?
推荐答案
可以使用 \A
转义序列在伪元素生成的内容中。在CSS2规范中阅读更多。
It's possible using the \A
escape sequence in the psuedo-element generated content. Read more in the CSS2 spec.
#restart:before { content: '\A'; }
您可能还需要添加 white-space:pre; code>到
#restart
。
注意: \A
表示行的结尾。
note: \A
denotes the end of a line.
ps另一种待遇是
:before { content: ' '; display: block; }
这篇关于如何在元素之前使用CSS插入换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文