你能添加换行符到:伪元素吗? [英] Can you add line breaks to the :after pseudo element?
问题描述
我要向特定类附加< br />
。使用:after伪类只显示< br />
为文本。
I want to append a <br />
to a particular class. Using the :after pseudo class simply displays <br />
as text.
使这项工作?
这是IE8的内部,所以浏览器的问题不是一个问题。如果我
It's internal for IE8 so browser issues aren't a problem. If I do
<span class="linebreakclass">cats are</span> brilliant
我希望brilliant出现在新行上。
I want "brilliant" to appear on a new line.
推荐答案
您将无法呈现HTML标签,但可以按如下方式设置样式:
You won't be able to render HTML tags but you can set style like this:
.needs-space:after
{
content: " ";
display: block;
clear: both; /* if you need to break floating elements */
}
display:block;
这将在 DIV
内呈现:内容。所有最新的浏览器都支持这个伪元素。包括IE。说这个你应该知道你的用户和他们的浏览器。
The main setting here is display: block;
This will render :after content inside a DIV
. And this pseudo element is supported by all latest browsers. Including IE. Saying this you should be aware of your users and their browsers.
这篇关于你能添加换行符到:伪元素吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!