试一试
word-spacing: normal;
word-spacing: 1rem;
word-spacing: 4px;
word-spacing: -0.4ch;
<section id="default-example">
<p id="example-element">
As much mud in the streets as if the waters had but newly retired from the
face of the earth, and it would not be wonderful to meet a Megalosaurus,
forty feet long or so, waddling like an elephantine lizard up Holborn Hill.
</p>
</section>
@font-face {
src: url("/shared-assets/fonts/variable-fonts/AmstelvarAlpha-VF.ttf");
font-family: "Amstelvar";
font-style: normal;
}
section {
font-size: 1.2em;
font-family: "Amstelvar", serif;
}
语法
css
/* Keyword value */
word-spacing: normal;
/* <length> values */
word-spacing: 3px;
word-spacing: 0.3em;
/* Global values */
word-spacing: inherit;
word-spacing: initial;
word-spacing: revert;
word-spacing: revert-layer;
word-spacing: unset;
值
无障碍
过大或过小的 word-spacing 值会使应用此样式的句子变得难以阅读。对于使用非常大的正值设置样式的文本,单词之间的距离会非常远,以至于不再像一个句子。对于使用非常大的负值设置样式的文本,单词会相互重叠,以至于每个单词的开头和结尾都无法识别。
可读的 word-spacing 必须根据具体情况确定,因为不同的字体系列具有不同的字符宽度。没有一个值可以确保所有字体系列自动保持其可读性。
示例
HTML
html
<div id="mozdiv1">Lorem ipsum dolor sit amet.</div>
<div id="mozdiv2">Lorem ipsum dolor sit amet.</div>
CSS
css
#mozdiv1 {
word-spacing: 15px;
}
#mozdiv2 {
word-spacing: 5em;
}
正式定义
| 初始值 | normal |
|---|---|
| 应用于 | 所有元素。也适用于 ::first-letter 和 ::first-line。 |
| 继承性 | 是 |
| 百分比 | 指受影响字形的宽度 |
| 计算值 | 绝对 <length> |
| 动画类型 | 一个长度 |
正式语法
word-spacing =
normal |
<length-percentage>
<length-percentage> =
<length> |
<percentage>
规范
| 规范 |
|---|
| CSS Text Module Level 3 # word-spacing-property |
| Scalable Vector Graphics (SVG) 2 # WordSpacingProperty |
浏览器兼容性
加载中…
另见
letter-spacing- SVG
word-spacing属性