--- title: 文本装饰线厚度(粗细) slug: Web/CSS/text-decoration-thickness tags: - 装饰线粗细 装饰线厚度 translation_of: Web/CSS/text-decoration-thickness original_slug: Web/CSS/文本装饰线厚度(粗细) ---
text-decoration-thickness 用于设置元素中文本所使用的装饰线(如 line-through、underline 或 overline)的笔触厚度。/* Single keyword */ text-decoration-thickness: auto; text-decoration-thickness: from-font; /* length */ text-decoration-thickness: 0.1em; text-decoration-thickness: 3px; /* percentage */ text-decoration-thickness: 10%; /* Global values */ text-decoration-thickness: inherit; text-decoration-thickness: initial; text-decoration-thickness: unset;
autofrom-fontauto 一样,由浏览器选择合适的厚度值。<length><percentage>{{CSSInfo}}
<p class="thin">Here's some text with a 1px red underline.</p> <p class="thick">This one has a 5px red underline.</p> <p class="shorthand">This uses the equivalent shorthand.</p>
.thin {
text-decoration-line: underline;
text-decoration-style: solid;
text-decoration-color: red;
text-decoration-thickness: 1px;
}
.thick {
text-decoration-line: underline;
text-decoration-style: solid;
text-decoration-color: red;
text-decoration-thickness: 5px;
}
.shorthand {
text-decoration: underline solid red 5px;
}
{{ EmbedLiveSample('Varying_thickness', '', '', '') }}
| Specification | Status | Comment |
|---|---|---|
| {{SpecName('CSS4 Text Decoration', '#text-decoration-width-property', 'text-decoration-width')}} | {{Spec2('CSS4 Text Decoration')}} | Initial definition. |
Note: The property used to be called text-decoration-width, but was updated in 2019 to text-decoration-thickness.
{{Compat("css.properties.text-decoration-thickness")}}