diff options
Diffstat (limited to 'files/zh-cn/web/css/text-decoration-thickness/index.html')
-rw-r--r-- | files/zh-cn/web/css/text-decoration-thickness/index.html | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/text-decoration-thickness/index.html b/files/zh-cn/web/css/text-decoration-thickness/index.html new file mode 100644 index 0000000000..cdffd6eced --- /dev/null +++ b/files/zh-cn/web/css/text-decoration-thickness/index.html @@ -0,0 +1,119 @@ +--- +title: 文本装饰线厚度(粗细) +slug: Web/CSS/文本装饰线厚度(粗细) +tags: + - 装饰线粗细 装饰线厚度 +translation_of: Web/CSS/text-decoration-thickness +--- +<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><length></code></dt> + <dd>将文本装饰线的厚度设置为一个 {{cssxref('length')}} 类型的值,覆盖掉字体文件建议的值或浏览器默认的值。</dd> + <dt><code><percentage></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> + +<pre class="syntaxbox notranslate">{{csssyntax}}</pre> + +<h2 id="示例">示例</h2> + +<h3 id="Varying_thickness">Varying thickness</h3> + +<h4 id="HTML">HTML</h4> + +<pre class="brush: html notranslate"><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></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> |