Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

这篇文章需要文法复核。如何帮忙。

翻译正在进行中。

简介

text-decoration 这个 CSS 属性是用于设置文本排版(下划线、顶划线、删除线或者闪烁)。下划线和顶划线修饰于文本的下部,删除线位于文本之上。

文本修饰属性会延伸到后代元素。这意味着如果祖先元素指定了文本修饰属性,后代元素则不能将其删除。例如,在如下标记中<p>This text has <em>some emphasized words</em> in it.</p>,应用样式p { text-decoration: underline } 会对整个段落添加下划线,再添加样式 em { text-decoration: none } 则不会引起任何改变;整个段落仍然有下划线修饰。然而,新加样式 em { text-decoration: overline } 则会在<em>标记的文字上添加另一种新样式。

注意: CSS Text Decoration Level 3把这种属性变换成如下三种简写方式:text-decoration-color, text-decoration-line,和 text-decoration-style。向其他任何简写属性一样,这表示如果简写方式没有明确设定,就把属性设置为默认值。

初始值as each of the properties of the shorthand:
适用元素all elements. It also applies to ::first-letter and ::first-line.
是否是继承属性
适用媒体visual
计算值as each of the properties of the shorthand:
Animation typeas each of the properties of the shorthand:
正规顺序order of appearance in the formal grammar of the values

语法

/*关键值*/
text-decoration: none;                     /*没有文本装饰*/
text-decoration: underline red;            /*红色下划线*/
text-decoration: underline wavy red;       /*红色波浪形下划线*/

/*全局值*/
text-decoration: inherit;
text-decoration: initial;
text-decoration: unset;

text-decoration属性是一种简写属性,并且可以使用普通属性三个值中的任何一个。普通属性如下:text-decoration-linetext-decoration-colortext-decoration-style

语法形式

<'text-decoration-line'> || <'text-decoration-style'> || <'text-decoration-color'>

例子

h1.under {
    text-decoration: underline;
}
h1.over {
    text-decoration: overline;
}
p.line {
    text-decoration: line-through;
}
p.blink {
    text-decoration: blink;
}
a.none {
    text-decoration: none;
}
p.underover {
    text-decoration: underline overline;
}

规范

规范 状态值 注解
CSS Text Decoration Level 3
text-decoration
Candidate Recommendation 转换为简写属性。支持text-decoration-style
CSS Level 2 (Revision 1)
text-decoration
Recommendation 没有显著变化
CSS Level 1
text-decoration
Recommendation 最初的规范

浏览器兼容性

特征 Firefox (Gecko) Chrome Internet Explorer Opera Safari
基本支持 1.0 (1.7 or earlier) 1.0 3.0 3.5 1.0

blink value

1.0 (1.7 or earlier)
Effect removed in 23.0 (23.0)
(Yes) but without effect (Yes) but without effect 4.0
Effect removed in 15.0
(Yes) but without effect
简写属性 6.0 (6.0) (partial)
36.0 (36.0)
未实现 未实现 未实现 7.1 [1]
 
特征 Firefox Mobile (Gecko) Android IE Phone Opera Mobile Safari Mobile
基本支持 1.0 (1.0) (Yes) (Yes) (Yes) (Yes)
blink 值 1.0 (1.7 or earlier)
Effect removed in 23.0 (23.0)
(Yes) but without effect (Yes) but without effect 4.0
Effect removed in 15.0
(Yes) but without effect
简写属性 6.0 (6.0) (partial)
36.0 (36.0)
? ? ? 8 [1]

[1]blink value没有任何效果.

[2]Safari 不支持text-decoration-style.

[3]这个版本的Gecko有一部分实现.

See also

参见

文档标签和贡献者

 此页面的贡献者: The-End-Hero, SunGuona, fscholz, Sebastianz, ziyunfei, Deguang
 最后编辑者: The-End-Hero,