【css】实现文字渐变+描边功能

一、渐变

1.效果图

2.代码

<div class="liner-style">
    我的渐变样式
</div>
.liner-style{
  font-size: 50px;
  font-weight: bold;
  color: transparent;
  background-image: linear-gradient(90deg,rgba(42, 130, 228, 1),rgba(139, 100, 245, 1));
  -webkit-background-clip: text;
  background-clip: text;
}

二、描边

1.效果图

2.代码

<div class="border-style" data-text="我的描边样式">
    我的描边样式
</div>
.border-style{
  position:relative;
  font-size: 50px;
  font-weight: bold;
  color: black;
}
.border-style::before {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  color: black;
  height: 100%;
  text-shadow: 3px 3px 0px #CD7F32, -3px -3px 0px #CD7F32, 3px -3px 0px #CD7F32, -3px 3px 0px #CD7F32;
}
.border-style::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  color: black;
  height: 100%;
  text-shadow: 3px 3px 0px #CD7F32, -3px -3px 0px #CD7F32, 3px -3px 0px #CD7F32, -3px 3px 0px #CD7F32;
}

三、渐变+描边

1.效果图

2.代码

<view class="liner-border-style" data-text="我的渐变描边样式">
    我的渐变描边样式
</view>
.liner-border-style{
  position:relative;
  font-size: 50px;
  font-weight: bold;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  background-image: linear-gradient(45deg,black,red);
}
.liner-border-style::before {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  color: transparent;
  text-shadow: 3px 3px 0px #CD7F32, -3px -3px 0px #CD7F32, 3px -3px 0px #CD7F32, -3px 3px 0px #CD7F32;
}
.liner-border-style::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  background-image: linear-gradient(45deg,black,red);
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值