word-spacing 属性允许更改一段文本中单词之间的空格,而不是单个字符。
此属性可以具有正值或者负值。
正值会在单词之间添加另外的空格,而负值会删除单词之间的空格。
当属性设置为“normal”时,定义的字体将指定单词之间的间距。
如果要删除行内块元素之间的空格,可以将 white-space 属性设置为“zero”。
word-spacing 属性可以使用 transition 属性进行动画处理。
word-spacing 属性用于内联内容。
初始值 | normal |
---|---|
AppliExamplees to | 所有元素。它还适用于伪元素::first-letter 和 ::first-line。 |
继承 | 可继承 |
可动画的 | 是的。单词间距是可动画的。 |
版本 | CSS1 |
DOM 语法 | object.Style.WordSpacing =“40px”; |
CSS word-spacing 属性值说明
值 | 描述 |
---|---|
normal | 指定正常的单词间距。这是此属性的默认值。 |
length | 指定另外的单词间距。可以在px,pt,cm,em等中指定负值是有效的。 |
initial | 使属性使用其默认值。 |
inherit | 从父母元素继承属性。 |
语法
word-spacing: normal | length | initial | inherit;
具有“normal”值的 word-spacing 属性示例:
<!DOCTYPE html> <html> <head> <title>文档的标题</title> <style> .text { word-spacing: normal; } </style> </head> <body> <h2>Word-spacing 属性示例</h2> <p class="text">生活终归还得继续。...</p> </body> </html>
在以下示例中,单词之间的间距为 20px:
“px”中指定的字间距属性示例:
<!DOCTYPE html> <html> <head> <title>文档的标题</title> <style> .text { word-spacing: 20px; } </style> </head> <body> <h2>Word-spacing 属性示例</h2> <p class="text">生活终归还得继续。...</p> </body> </html>
日期:2020-06-02 22:14:52 来源:oir作者:oir