演示空白属性的不同值:
p.a {
white-space: nowrap;
}
p.b {
white-space: normal;
}
p.c {
white-space: pre;
}
亲自试一试 »
这个white-space
属性指定如何处理元素内的空白。
表中的数字指定完全支持该属性的第一个浏览器版本。
Property | |||||
---|---|---|---|---|---|
white-space | 1.0 | 8.0 | 3.5 | 3.0 | 9.5 |
white-space: normal|nowrap|pre|pre-line|pre-wrap|initial|inherit;
Value | Description | Demo |
---|---|---|
normal | Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary. This is default | Demo ❯ |
nowrap | Sequences of whitespace will collapse into a single whitespace. Text will never wrap to the next line. The text continues on the same line until a <br> tag is encountered | Demo ❯ |
pre | Whitespace is preserved by the browser. Text will only wrap on line breaks. Acts like the <pre> tag in HTML | Demo ❯ |
pre-line | Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary, and on line breaks | Demo ❯ |
pre-wrap | Whitespace is preserved by the browser. Text will wrap when necessary, and on line breaks | Demo ❯ |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
CSS教程:CSS 文本间距
HTML DOM 参考:空白属性
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!