找回密码
 立即注册
点击图片立即观看
搜索
查看: 25|回复: 0

CSS 文字渐变

[复制链接]
发表于 2026-9-2 20:59:22 |北京| 显示全部楼层 |阅读模式
HTML代码
  1. <div class="gradient1">
  2.   <span>渐变1 - 菜鸟工具</span>
  3. </div>
  4. <h2 class="text-gradient" data-text="渐变2 - 菜鸟工具">渐变2 - 菜鸟工具</h2>
复制代码
CSS 代码
  1. .gradient1 span {
  2.   background: linear-gradient(to right, red, blue);
  3.   -webkit-background-clip: text;
  4.   color: transparent;
  5. }
  6. .text-gradient {  
  7.   display: inline-block;
  8.   font-family: '微软雅黑';
  9.   font-size: 2em;
  10.   position: relative;
  11. }  

  12. .text-gradient[data-text]::after {  
  13.   content: attr(data-text);  
  14.   color: green;  
  15.   position: absolute;  
  16.   left: 0;  
  17.   z-index: 2;
  18.   -webkit-mask-image: -webkit-gradient(linear, 0 0, 0 bottom, from(#ff0000), to(rgba(0, 0, 255, 0)));
  19. }
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|B.K 网络工作室

GMT+8, 2026-9-14 20:06 , Processed in 0.020314 second(s), 16 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表