html怎么添加文字和下划线,如何增加CSS中文本和下划线之间的差距

squarecandy..

11

深入了解视觉风格的细节text-decoration:underline几乎是徒劳的,所以你将不得不采用某种方式去除删除text-decoration:underline并用其他内容替换它,直到一个神奇的远期未来版本的CSS给我们更多的控制权.

这对我有用:

a {

background-image: linear-gradient(

180deg, rgba(0,0,0,0),

rgba(0,0,0,0) 81%,

#222222 81.1%,

#222222 85%,

rgba(0,0,0,0) 85.1%,

rgba(0,0,0,0)

);

text-decoration: none;

}

调整%值(81%和85%)以更改行与文本的距离

调整两个%值之间的差异以更改线条粗细

调整颜色值(#222222)以更改下划线颜色

适用于多行内联元素

适用于任何背景

这是一个具有所有专有属性的版本,具有一些向后兼容性:

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore.

更新:SASSY版本

我为此做了一个scss mixin.如果您不使用SASS,上面的常规版本仍然很好...

a {

/* This code generated from: http://colorzilla.com/gradient-editor/ */

background: -moz-linear-gradient(top, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 81%, rgba(0,0,0,1) 81.1%, rgba(0,0,0,1) 85%, rgba(0,0,0,0) 85.1%, rgba(0,0,0,0) 100%); /* FF3.6+ */

background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0)), color-stop(81%,rgba(0,0,0,0)), color-stop(81.1%,rgba(0,0,0,1)), color-stop(85%,rgba(0,0,0,1)), color-stop(85.1%,rgba(0,0,0,0)), color-stop(100%,rgba(0,0,0,0))); /* Chrome,Safari4+ */

background: -webkit-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0) 81%,rgba(0,0,0,1) 81.1%,rgba(0,0,0,1) 85%,rgba(0,0,0,0) 85.1%,rgba(0,0,0,0) 100%); /* Chrome10+,Safari5.1+ */

background: -o-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0) 81%,rgba(0,0,0,1) 81.1%,rgba(0,0,0,1) 85%,rgba(0,0,0,0) 85.1%,rgba(0,0,0,0) 100%); /* Opera 11.10+ */

background: -ms-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0) 81%,rgba(0,0,0,1) 81.1%,rgba(0,0,0,1) 85%,rgba(0,0,0,0) 85.1%,rgba(0,0,0,0) 100%); /* IE10+ */

background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,0) 81%,rgba(0,0,0,1) 81.1%,rgba(0,0,0,1) 85%,rgba(0,0,0,0) 85.1%,rgba(0,0,0,0) 100%); /* W3C */

text-decoration: none;

}

然后像这样使用它:

@mixin fake-underline($color: #666, $top: 84%, $bottom: 90%) {

background-image: linear-gradient(

180deg, rgba(0,0,0,0),

rgba(0,0,0,0) $top,

$color $top + 0.1%,

$color $bottom,

rgba(0,0,0,0) $bottom + 0.1%,

rgba(0,0,0,0)

);

text-decoration: none;

}

更新2:下降提示

如果你有一个坚实的背景颜色,尝试添加一个薄text-stroke或text-shadow与你的背景相同的颜色,使下降器看起来不错.

信用

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值