html 怎样消除盒子的换行,html – 如何改变CSS中的删除/换行厚度?

这里有一个纯CSS方法,不需要任何不必要的包装元素。作为一个额外的好处,您不仅可以调整删除的厚度,但你可以控制其颜色与文本颜色分开:

.strikeout {

font-size: 4em;

line-height: 1em;

position: relative;

}

.strikeout::after {

border-bottom: 0.125em solid red;

content: "";

left: 0;

margin-top: calc(0.125em / 2 * -1);

position: absolute;

right: 0;

top: 50%;

}

Struck out text

使用RGBa颜色使删除半透明:

.strikeout {

font-size: 4em;

position: relative;

}

.strikeout::after {

border-bottom: 0.125em solid rgba(255, 0, 0, 0.5);

content: "";

left: 0;

line-height: 1em;

margin-top: calc(0.125em / 2 * -1);

position: absolute;

right: 0;

top: 50%;

}

Struck out text

或者甚至使罢工梯度!只需使用背景结合高度,代替边框:

.strikeout {

font-size: 4em;

line-height: 1em;

position: relative;

}

.strikeout::after {

background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 0, 0, 1), rgba(0, 255, 0, 1), rgba(0, 0, 255, 1), rgba(255, 255, 255, 0));

content: "";

height: 0.125em;

left: 0;

margin-top: calc(0.125em / 2 * -1);

position: absolute;

right: 0;

top: 50%;

}

Struck out text

这在IE9(无梯度)和向上 – 甚至IE8如果你使用单冒号:后语法和手动写负边距顶值而不是使用calc()。

主要的缺点是,这只工作在一行文本。但嘿,你拿你可以得到;-)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值