在线文档教程
CSS

文本装饰-颜色 | text-decoration-color

text-decoration-color

text-decoration-color CSS属性设置由text-decoration-line属性所指定的线条的颜色。该颜色会应用于所有指定的线条。当一次设置多个线条装饰属性时,使用text-decoration简写属性可能会更方便。

/* <color> values */ text-decoration-color: currentColor; text-decoration-color: red; text-decoration-color: #00ff00; text-decoration-color: rgba(255, 128, 128, 0.5 text-decoration-color: transparent; /* Global values */ text-decoration-color: inherit; text-decoration-color: initial; text-decoration-color: unset;

CSS不提供为每种线类型指定唯一颜色的直接机制。然而,这种效果可以通过嵌套元素实现:即对每个元素应用不同的线条类型(通过text-decoration-line属性),并以每个元素为基础指定线条颜色(通过text-decoration-color属性)来实现。

Initial valuecurrentcolor
Applies toall elements. It also applies to ::first-letter and ::first-line.
Inheritedno
Mediavisual
Computed valuecomputed color
Animation typea color
Canonical orderthe unique non-ambiguous order defined by the formal grammar

语法

可能值

<color>装饰线条的颜色。

形式语法

<color>where <color> = <rgb()> | <rgba()> | <hsl()> | <hsla()> | <hex-color> | <named-color> | currentcolor | <deprecated-system-color> where <rgb()> = rgb( [ [ <percentage>{3} | <number>{3} ] [ / <alpha-value> ]? ] | [ [ <percentage>#{3} | <number>#{3} ] , <alpha-value>? ] ) <rgba()> = rgba( [ [ <percentage>{3} | <number>{3} ] [ / <alpha-value> ]? ] | [ [ <percentage>#{3} | <number>#{3} ] , <alpha-value>? ] ) <hsl()> = hsl( [ <hue> <percentage> <percentage> [ / <alpha-value> ]? ] | [ <hue>, <percentage>, <percentage>, <alpha-value>? ] ) <hsla()> = hsla( [ <hue> <percentage> <percentage> [ / <alpha-value> ]? ] | [ <hue>, <percentage>, <percentage>, <alpha-value>? ] ) where <alpha-value> = <number> | <percentage> <hue> = <number> | <angle>

实例

<p>This paragraph has <s>some erroneous text</s> inside it that I want to call attention to.</p>

p { text-decoration-line: underline; text-decoration-color: cyan; } s { text-decoration-line: line-through; text-decoration-color: red; text-decoration-style: wavy; }

规范

SpecificationStatusComment
CSS Text Decoration Module Level 3The definition of 'text-decoration-color' in that specification.Candidate RecommendationInitial definition. The text-decoration property is now a shorthand to define multiple related properties.

浏览器兼容性

FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support576.0 (6.0) - 39.0 (39.0)-moz 36.0 (36.0) without prefixNo support447.1 -webkit

FeatureAndroid WebviewChrome for AndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support57576.0 (6.0) - 39.0 (39.0)-moz 36.0 (36.0) without prefixNo support448 -webkit