css 文字下划线 text-decoration

背景:

在某些时候需要给文字添加特殊样式。使用 text-decoration: underline; 来为段落文字添加下划线。也有其它文本装饰样式,例如:

  • none:无装饰(去掉装饰)
  • overline:上划线
  • line-through:贯穿线(删除线)

效果展示:

 

样式代码:

cursor: pointer;
color: #2770d4;//一种蓝色
text-decoration: underline;

写到这儿就结束了,下面是扩展:

二、其它

可以使用 text-decoration 的细化属性来更详细地控制下划线的样式,比如颜色、样式和位置:

运行代码:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>CSS 详细控制下划线样式示例</title>
  <style>
    .custom-underline {
      text-decoration-line: underline;
      text-decoration-color: red; /* 设置下划线颜色 */
      text-decoration-style: dashed; /* 设置下划线样式 */
      text-underline-position: under; /* 设置下划线位置 */
    }
  </style>
</head>
<body>
  <p class="custom-underline">这是带有自定义下划线样式的文字。</p>
</body>
</html>

三、其它2

可以组合这些装饰效果,例如:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>CSS 组合文字装饰示例</title>
  <style>
    .multiple-decoration {
      text-decoration: underline overline;
    }
  </style>
</head>
<body>
  <p class="multiple-decoration">这是同时带有下划线和上划线的文字。</p>
</body>
</html>

 

 

 

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值