DigitalOcean 为您旅程的每个阶段提供云产品。 立即开始使用 免费赠送的 200 美元!
text-decoration-skip-ink
是一个属性,用于控制 underline
和 overline
(但不是 line-through
)在穿过字符/字形一部分时的行为。 这让您可以微调控制下划线或上划线如何与超出顶线或悬挂在底线下方字符交互。
之前,这通过 text-decoration-skip: ink;
属性/值组合来处理,但在讨论如何处理层叠样式无意中覆盖低优先级样式(由于 text-decoration-skip
可用选项数量)的问题后,各个属性将被分解成类似于 text-decoration-skip-ink
的新属性。 有关更改原因的更多背景信息和示例,请参阅 此 GitHub 讨论 和 CSS 工作组会议记录,其中讨论了这些属性。
默认情况下,浏览器会“跳过”字符“墨迹”与下划线交叉的区域,如下所示

您可以通过将 text-decoration-skip-ink
设置为 none
来更改此行为,从而强制下划线/上划线穿过字符。
.line-of-text-thats-already-underlined {
text-decoration-skip-ink: none;
}
这会导致线条直接穿过字符

语法
text-decoration-skip-ink: auto | none;
值
text-decoration-skip-ink
接受以下值
auto
是默认值,将在穿过字符时“跳过”下划线/上划线。none
将直接穿过悬挂的 y 和高耸的 t,将下划线/上划线切断。
示例
浏览器支持
此浏览器支持数据来自 Caniuse,其中提供了更多详细信息。 数字表示浏览器在该版本及其更高版本上支持该功能。
桌面
Chrome | Firefox | IE | Edge | Safari |
---|---|---|---|---|
130 | 132 | 否 | 127 | TP |
移动/平板电脑
Android Chrome | Android Firefox | Android | iOS Safari |
---|---|---|---|
127 | 127 | 127 | 18.0* |
更多信息
相关
text-decoration
.element { text-decoration: underline; }
text-decoration-color
.element { text-decoration-color: orange; }
text-decoration-line
.element { text-decoration-line: underline; }
text-decoration-skip
.element { text-decoration-skip: ink; }
text-decoration-style
.element { text-decoration-style: wavy; }
text-decoration-thickness
.element { text-decoration-thickness: 2px; }