• 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;
    
  • 相关阅读:
    标签属性 rel=“noopener noreferrer“ 原来这么有用
    Python:实现merge sort归并排序算法(附完整源码)
    驱动开发:内核特征码扫描PE代码段
    java设计模式之原型模式
    Python技法:浮点数取整、格式化和NaN处理
    Maven分离资源文件
    贪心二分之分组组队
    新型攻击方法分析
    Echarts渲染不报错但是没有内容
    Linux-进程和计划任务管理⭐
  • 原文地址:https://blog.csdn.net/qq_52395343/article/details/140374707