• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • text-underline-position

    版本:CSS3

    当 text-decoration属性的值设置为 underline 之后,可以用 text-underline-position 属性为其设置下划线的位置。

    示例

    /* 只设置一个属性值 */
    text-underline-position: auto;
    text-underline-position: under;
    text-underline-position: left;
    text-underline-position: right;
    
    /* 设置多个属性值 */
    text-underline-position: under left;
    text-underline-position: right under;
    
    /* 全局属性值 */
    text-underline-position: inherit;
    text-underline-position: initial;
    text-underline-position: unset;
    

    浏览器支持

    IE浏览器火狐浏览器opera浏览器chrome浏览器safari浏览器
    火狐浏览器、safari浏览器不支持text-underline-position。其余浏览器都支持text-underline-position

    语法:

    text-underline-position: auto | under | left | right | auto-pos | above | below

    取值

    • auto:用户代理会根据自己的算法来确认下划线是放在字母基线上还是放在字母基线下方。
    • under:强制下划线的位置为字母基线的下方,在这个位置,下划线不会穿过任何字母,这样能确保数学方程式或者化学式的下标不会被下划线阻挡。
    • left:在垂直排版模式下,使下划线的位置在文字的左侧,在水平排版模式下,和under相同。
    • right:在垂直排版模式下,使下划线的位置在文字的右侧,在水平排版模式下,和under相同。
    • auto-posauto的同义词,应使用auto
    • above:强制下划线放置于文本上面。当使用东亚文字时,此效果和使用auto相同。
    • below:强制下划线放置于文本下面。当使用字母文字的时候,此效果和使用auto相同。
    默认值auto
    适用于所有元素
    继承性
    动画性
    计算值指定值

    例子

    由于text-underline-position属性可以继承,且无法用text-decoration简写属性重置,所以应当在全局级别设置其值。比如,under值对一篇包括大量使用下标的数学或者化学公式的文档是非常有用的。

    :root {
      text-underline-position: under;
    }
    

    上篇:text-decoration-skip

    下篇:text-shadow