为 <h1>、<h2> 和 <h3> 元素设置不同的文本装饰:
h1 {
text-decoration: overline;
}
h2 {
text-decoration: line-through;
}
h3 {
text-decoration: underline;
}
h4 {
text-decoration: underline overline;
}
亲自试一试 »
下面有更多 "亲自试一试" 示例。
这个text-decoration
property 指定添加到文本的装饰,并且是以下属性的简写属性:
默认值: | 没有任何当前颜色固体汽车 |
---|---|
遗传: | 不 |
可动画: | 不,查看各个属性。阅读可动画的 |
版本: | CSS1,在 CSS3 中更新 |
JavaScript 语法: | 对象.style.textDecoration="underline"尝试一下 |
表中的数字指定完全支持该属性的第一个浏览器版本。
Property | |||||
---|---|---|---|---|---|
text-decoration | 1.0 | 3.0 | 1.0 | 1.0 | 3.5 |
text-decoration:
text-decoration-line
text-decoration-color
text-decoration-style text-decoration-thickness|initial|inherit;
Value | Description | Demo |
---|---|---|
text-decoration-line | Sets the kind of text decoration to use (like underline, overline, line-through) | Demo ❯ |
text-decoration-color | Sets the color of the text decoration | Demo ❯ |
text-decoration-style | Sets the style of the text decoration (like solid, wavy, dotted, dashed, double) | Demo ❯ |
text-decoration-thickness | Sets the thickness of the decoration line | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
添加更多文字装饰:
h1 {
text-decoration: underline overline dotted red;
}
h2 {
text-decoration: underline wavy blue 5px;
}
亲自试一试 »
CSS教程:CSS 文本装饰
HTML DOM 参考:textDecoration 属性
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!