本文介绍了换行符(如< br>)仅使用css的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有可能在纯CSS,即没有添加额外的html标签,使一个换行符< br> ?我想在< h4> 元素之后但不在之前的换行:

Is it possible in pure css, that is without adding additional html tags, to make a line break like <br>? I want the line break after the <h4> element, but not before:

HTML

<li>
  Text, text, text, text, text. <h4>Sub header</h4>
  Text, text, text, text, text.
</li>

CSS

h4 {
  display: inline;
}



我发现了很多问题,当< h4> 必须保持在同一行时,use display:block; b $ b

I have found many questions like this, but always with answers like "use display: block;", which I can't do, when the <h4> must stay on the same line.

推荐答案

它的工作原理如下:

h4 {
    display:inline;
}
h4:after {
    content:"\a";
    white-space: pre;
}

示例:

诀窍来自这里:(有更多说明)

The trick comes from here: http://stackoverflow.com/a/66000/509752 (to have more explanation)

这篇关于换行符(如&lt; br&gt;)仅使用css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 18:45
查看更多