CSS text-underline-offset 屬性

定義和用法

text-underline-offset 屬性指定下劃線文本裝飾的偏移距離。

實例

設置下劃線文本裝飾的偏移距離:

div.a {
  text-decoration: underline;
}
div.b {
  text-decoration: underline;
  text-underline-offset: 10px;
}
div.c {
  text-decoration: underline wavy blue;
}
div.d {
  text-decoration: underline wavy blue;
  text-underline-offset: 10px;
}

親自試一試

CSS 語法

text-underline-offset: auto|length|percentage|initial|inherit;

屬性值

描述
auto 默認值。瀏覽器為下劃線設置適當的偏移量。
length 指定偏移量為長度值。
percentage 指定偏移量為百分比值。
initial 將此屬性設置為其默認值。參閱 initial
inherit 從其父元素繼承此屬性。參閱 inherit

技術細節

默認值: auto
繼承性: yes
動畫制作: 不支持。請參閱:動畫相關屬性
版本: CSS4
JavaScript 語法: object.style.textUnderlineOffset="1em"

瀏覽器支持

表格中的數字表示首個完全支持該屬性的瀏覽器版本。

Chrome Edge Firefox Safari Opera
87.0 87.0 70.0 12.1 73.0

相關頁面

教程:CSS 文本裝飾

參考:HTML DOM textDecoration 屬性