首页 话题 小组 问答 好文 用户 我的社区 域名交易 唠叨

[分享]css中如何设置下划线的颜色

发布于 2024-11-11 19:22:13
0
23

CSS中设置下划线的颜色可以通过text-decoration-color属性来实现。

span {
  text-decoration: underline;
  text-decoration-color: red;
} 

上述代码中,我们为span元素设置了下划线,并且将下划线的颜色设置为红色。

如果想让下划线的颜色和文本颜色一样,可以使用currentColor关键字。

span {
  text-decoration: underline;
  text-decoration-color: currentColor;
  color: blue;
} 

在上述代码中,我们让下划线的颜色等于文本颜色,即让下划线和文字都是蓝色。

需要注意的是,text-decoration-color属性不支持IE浏览器,但可以使用border-bottom代替下划线的效果,并且设置border-color属性来实现颜色的改变。

评论
一个月内的热帖推荐
91云脑
Lv.1普通用户

62849

帖子

14

小组

291

积分

赞助商广告
站长交流