css文本划线效果(text-decoration相关属性详解)

在这里插入图片描述

    /* 样式类型*/
  text-decoration: underline;
  /* 下划线颜色 */
  text-decoration-color: #ffcb15;
  /* 超出基线的字符不会被截断 */
  text-decoration-skip-ink: none;
  /*下划线厚度 */
  text-decoration-thickness: 5px;
  /* 与其原始位置的偏移距离 */
  text-underline-offset: 0;

1. text-underline-offset

使用 text-decoration时,设置文本装饰下划线与其原始位置的偏移距离
具体用法:

/* auto: 浏览器为下划线选择适当的偏移量*/
text-underline-offset: auto;

/* length:指定下划线偏移量 */
text-underline-offset: 0.1em;
text-underline-offset: 3px;

/* 百分比*/
text-underline-offset: 20%;

/* 全局值 */
text-underline-offset: inherit;
text-underline-offset: initial;
text-underline-offset: revert;
text-underline-offset: revert-layer;
text-underline-offset: unset;

注意:该属性不是text-decoration的简写属性!!

2. text-decoration

设置文本上的装饰性线条的样式。
该属性是 text-decoration-colortext-decoration-linetext-decoration-styletext-decoration-thickness的简写属性。

text-decoration-line:设置文本修饰线的类型,underline(在文本的下方)、overline(在文本的上方)、line-through(贯穿文本中间)
在这里插入图片描述

text-decoration-style: 设定的线的样式,solid(直线)、double(双下划线)、dotted(点画线)、dashed(虚线)、wavy(波浪线)
在这里插入图片描述

text-decoration-color:设置文本修饰线的颜色
text-decoration-thickness:设置文本修饰线的厚度

在这里插入图片描述

  text-decoration: underline wavy red;
  text-underline-offset: 3px;

3. text-decoration-skip-ink

设置如何绘制超出基线的字符。

默认值为auto下,超出基线的字符浏览器会进行截断:
在这里插入图片描述
设置为none,会直接穿过字体的超出部分,不会被截断:

  text-decoration: underline red;
  text-decoration-skip-ink: none;
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值