aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/text-decoration-thickness/index.html
blob: 4c2a07a01ed37dfa50e936882c4d31471f5411ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
title: 文本装饰线厚度(粗细)
slug: Web/CSS/text-decoration-thickness
tags:
  - 装饰线粗细 装饰线厚度
translation_of: Web/CSS/text-decoration-thickness
original_slug: Web/CSS/文本装饰线厚度(粗细)
---
<div>{{CSSRef}}</div>

<div><a href="/en-US/docs/CSS">CSS</a> 属性 <strong><code>text-decoration-thickness</code></strong> 用于设置元素中文本所使用的装饰线(如 line-through、underline 或 overline)的笔触厚度。</div>

<h2 id="语法">语法</h2>

<pre class="brush:css no-line-numbers notranslate">/* 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;</pre>

<h3 id="值"></h3>

<dl>
 <dt><code>auto</code></dt>
 <dd>由浏览器为文本装饰线选择合适的厚度。</dd>
 <dt><code>from-font</code></dt>
 <dd>如果字体文件中包含了首选的厚度值,则使用字体文件的厚度值。如果字体文件中没有包含首选的厚度值,则效果和设置为 <code>auto</code> 一样,由浏览器选择合适的厚度值。</dd>
 <dt><code>&lt;length&gt;</code></dt>
 <dd>将文本装饰线的厚度设置为一个 {{cssxref('length')}} 类型的值,覆盖掉字体文件建议的值或浏览器默认的值。</dd>
 <dt><code>&lt;percentage&gt;</code></dt>
 <dd>Specifies the thickness of the text decoration line as a {{cssxref('percentage')}} of <strong>1em</strong> in the current font. A percentage inherits as a relative value, and so therefore scales with changes in the font. The browser must use a minimum of 1 device pixel. For a given application of this property, the thickness is constant across the whole box it is applied to, even if there are child elements with a different font size.</dd>
</dl>

<h2 id="Formal_definition">Formal definition</h2>

<p>{{CSSInfo}}</p>

<h2 id="Formal_syntax">Formal syntax</h2>

{{csssyntax}}

<h2 id="示例">示例</h2>

<h3 id="Varying_thickness">Varying thickness</h3>

<h4 id="HTML">HTML</h4>

<pre class="brush: html notranslate">&lt;p class="thin"&gt;Here's some text with a 1px red underline.&lt;/p&gt;
&lt;p class="thick"&gt;This one has a 5px red underline.&lt;/p&gt;
&lt;p class="shorthand"&gt;This uses the equivalent shorthand.&lt;/p&gt;</pre>

<h4 id="CSS">CSS</h4>

<pre class="brush: css notranslate">.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;
}</pre>

<h4 id="Results">Results</h4>

<p>{{ EmbedLiveSample('Varying_thickness', '', '', '') }}</p>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS4 Text Decoration', '#text-decoration-width-property', 'text-decoration-width')}}</td>
   <td>{{Spec2('CSS4 Text Decoration')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<div class="blockIndicator note">
<p><strong>Note</strong>: The property used to be called <code>text-decoration-width</code>, but was updated in 2019 to <code>text-decoration-thickness</code>.</p>
</div>

<h2 id="浏览器兼容性">浏览器兼容性</h2>



<p>{{Compat("css.properties.text-decoration-thickness")}}</p>

<h2 id="相关链接">相关链接</h2>

<ul>
 <li>{{cssxref("text-decoration")}}</li>
 <li>{{cssxref("text-underline-offset")}}</li>
</ul>