[英]How can I make an inline span tag to go to the next line without having to change its display to block?
How can I make an inline span
tag to go to the next line without having to change its display to block? 如何使内联
span
标记转到下一行而不必将其显示更改为块?
I want to preserve its inline behaviours because the span
tag is meant to contain a short message. 我想保留其内联行为,因为
span
标记旨在包含一条短消息。 However, because it is inline, its position continues from its previous element (beside its previous element). 但是,因为它是内联的,所以它的位置从前一个元素继续(在前一个元素旁边)。 I need the span to position to the next line, that's, below its previous element rather than side by side.
我需要跨度来定位到下一行,即低于其前一个元素而不是并排。
Is it possible to do this without changing its display to block? 是否可以在不将其显示更改为阻止的情况下执行此操作?
Use this: 用这个:
span:before{
content: '\a' ;
white-space: pre;
}
The \\a
is from: http://www.w3.org/TR/CSS2/syndata.html#strings : \\a
来自: http : //www.w3.org/TR/CSS2/syndata.html#strings :
A string cannot directly contain a newline. 字符串不能直接包含换行符。 To include a newline in a string, use an escape representing the line feed character in ISO-10646 (U+000A), such as "\\A" or "\\00000a".
要在字符串中包含换行符,请使用表示ISO-10646(U + 000A)中换行符的转义符,例如“\\ A”或“\\ 00000a”。 This character represents the generic notion of "newline" in CSS.
此字符表示CSS中“newline”的一般概念。
You could throw the span into a block element, like a paragraph element. 您可以将span转换为块元素,就像段落元素一样。 Or you could place an invisible horizontal rule between the span and the elements you want to be on the previous line.
或者,您可以在跨度和要在前一行上的元素之间放置一条不可见的水平线。 Or you could throw in a line break element.
或者你可以抛出换行元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.