text-decoration-style
text-decoration-style CSS 属性用于设置 text-decoration-line 指定的文本装饰线的样式。该样式适用于所有通过 text-decoration-line 设置的文本装饰线。
试一试
text-decoration-style: solid;
text-decoration-style: double;
text-decoration-style: dotted;
text-decoration-style: dashed;
text-decoration-style: wavy;
<section id="default-example">
<p>
I'd far rather be
<span class="transition-all" id="example-element">happy than right</span>
any day.
</p>
</section>
p {
font: 1.5em sans-serif;
}
#example-element {
text-decoration-line: underline;
}
如果指定的装饰具有特定的语义含义,例如表示某些文本已被删除的删除线,建议作者使用 HTML 标签(如 <del> 或 <s>)来表示此含义。由于浏览器在某些情况下可能会禁用样式,因此在这种情况下,语义含义不会消失。
当同时设置多个线条装饰属性时,使用 text-decoration 简写属性可能更方便。
语法
css
/* Keyword values */
text-decoration-style: solid;
text-decoration-style: double;
text-decoration-style: dotted;
text-decoration-style: dashed;
text-decoration-style: wavy;
/* Global values */
text-decoration-style: inherit;
text-decoration-style: initial;
text-decoration-style: revert;
text-decoration-style: revert-layer;
text-decoration-style: unset;
值
正式定义
| 初始值 | solid |
|---|---|
| 应用于 | 所有元素。也适用于 ::first-letter 和 ::first-line。 |
| 继承性 | 否 |
| 计算值 | 同指定值 |
| 动画类型 | 离散 |
正式语法
text-decoration-style =
solid |
double |
dotted |
dashed |
wavy
示例
设置波浪下划线
以下代码将创建一个红色波浪下划线
CSS
css
.wavy {
text-decoration-line: underline;
text-decoration-style: wavy;
text-decoration-color: red;
}
HTML
html
<p class="wavy">This text has a wavy red line beneath it.</p>
结果
规范
| 规范 |
|---|
| CSS 文本装饰模块级别 3 # text-decoration-style 属性 |
浏览器兼容性
加载中…
另见
- 当同时设置多个线条装饰属性时,使用
text-decoration简写属性可能更方便。 text-decoration-linetext-decoration-colortext-decoration-thicknesstext-underline-offset