如何实现相同的输出没有<br>?
<p>hello <br> How are you </p>
输出:
hello How are you
如何实现相同的输出没有<br>?
<p>hello <br> How are you </p>
输出:
hello How are you
当前回答
代码可以是:
<div class="text-class"><span>hello</span><span>How are you</span></div>
CSS将是:
.text-class {
display: flex;
justify-content: flex-start;
flex-direction: column;
align-items: center;
}
其他回答
你可以使用空格:pre;使元素像<pre>一样,保留换行符。例子:
p { 空白:前; } < p >你好 </p>
注意,对于IE,这只适用于IE8+。
我喜欢非常简单的解决方案,这里还有一个:
<p>hello <span>How are you</span></p>
和CSS:
p {
display: flex;
flex-direction: column;
}
<pre>标签呢?
来源:http://www.w3schools.com/tags/tag_pre.asp
如果这能帮助到某人…
你可以这样做:
<p>This is an <a class="on-new-line">inline link</a>?</p>
用这个css:
a.on-new-line:before {
content: ' ';
font-size:0;
display:block;
line-height:0;
}
设置一个br标记来显示:none是有帮助的,但是你可以用WordsRunTogether结束。我发现用空格字符代替它更有帮助,就像这样:
HTML:
<h1>
Breaking<br />News:<br />BR<br />Considered<br />Harmful!
</h1>
CSS:
@media (min-device-width: 1281px){
h1 br {content: ' ';}
h1 br:after {content: ' ';}
}