CSS text-underline-position 属性

定义和用法

text-underline-position 属性指定下划线文本装饰的位置。

实例

设置下划线文本装饰的位置:

div.a {
  text-decoration: underline;
  text-underline-position: auto;
}

div.b {
  text-decoration: underline;
  text-underline-position: under;
}

亲自试一试

CSS 语法

text-underline-position: auto|under|from-font|left|right|initial|inherit;

属性值

描述
auto 默认值。浏览器设置下划线的位置。
under 将下划线设置在字母基线下方。
from-font

如果字体文件包含关于下划线位置的信息,则使用该值。

否则,使用 auto。

left

在垂直书写模式下,下划线将放置在文本的左侧。

在水平书写模式下,下划线将按照 auto 放置。

right

在垂直书写模式下,下划线将放置在文本的右侧。

在水平书写模式下,下划线将按照 auto 放置。

initial 将此属性设置为其默认值。参阅 initial
inherit 从其父元素继承此属性。参阅 inherit

技术细节

默认值: auto
继承性: yes
动画制作: 不支持。请参阅:动画相关属性
版本: CSS3
JavaScript 语法: object.style.textUnderlinePosition="under"

浏览器支持

表格中的数字表示首个完全支持该属性的浏览器版本。

Chrome Edge Firefox Safari Opera
33.0 79.0 74.0 12.1 20.0

相关页面

教程:CSS 文本装饰

参考:HTML DOM textDecoration 属性