当前位置: 首页 > news >正文

【CSS】如何写渐变色文字并且有打光效果

在这里插入图片描述
效果如上,其实核心除了渐变色文字的设置

 background: linear-gradient(270deg, #d2a742 94%, #f6e2a7 25%, #d5ab4a 48%, #f6e2a7 82%, #d1a641 4%);
 color: #e8bb2c;
 background-clip: text;
 color: transparent;

还有就是打光效果,原理其实就是两块遮罩,如下👇

在这里插入图片描述

完整代码

自己再根据自己需求调整下就行

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Draw a Ball</title>
    <style>
      /* From Uiverse.io by Spacious74 */
      .outer {
        width: 300px;
        height: 250px;
        border-radius: 10px;
        padding: 1px;
        background: radial-gradient(circle 230px at 0% 0%, #ffffff, #0c0d0d);
        position: relative;
      }

      .card {
        z-index: 1;
        width: 100%;
        height: 100%;
        border-radius: 9px;
        border: solid 1px #202222;
        background-size: 20px 20px;
        /* background: radial-gradient(circle 280px at 0% 0%, #fef3ef, #0c0d0d); */
        background-color: #fef3ef;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        flex-direction: column;
        color: #fff;
      }
      .ray {
        width: 200px;
        height: 45px;
        border-radius: 100px;
        position: absolute;
        background-color: red;
        background-color: #fff;
        opacity: 0.4;
        box-shadow: 0 0 50px #fff;
        filter: blur(10px);
        transform-origin: 10%;
        top: 0%;
        left: -54px;
        transform: rotate(46deg);
      }
      .ray2 {
        width: 200px;
        height: 45px;
        border-radius: 100px;
        position: absolute;
        background-color: red;
        background-color: #fff;
        opacity: 0.4;
        box-shadow: 0 0 50px #fff;
        filter: blur(10px);
        transform-origin: 10%;
        top: 0%;
        left: 54px;
        transform: rotate(46deg);
      }

      .card .text {
        font-weight: bolder;
        font-size: 4rem;
        background: linear-gradient(270deg, #d2a742 94%, #f6e2a7 25%, #d5ab4a 48%, #f6e2a7 82%, #d1a641 4%);
        color: #e8bb2c;
        background-clip: text;
        color: transparent;
      }

      .line {
        width: 100%;
        height: 1px;
        position: absolute;
        background-color: #2c2c2c;
      }

    </style>
  </head>
  <body>
    <div class="outer">
      <div class="card">
        <div class="ray"></div>
        <div class="ray2"></div>
        <div class="text">No.27</div>
      </div>
    </div>
  </body>
</html>

相关文章:

  • 华为人工智能重要服务总结
  • HALCON根据需要创建自定义函数
  • 【无人机设计与控制】 四轴飞行器的位移控制
  • 真实案例分享:零售企业如何避免销售数据的无效分析?
  • Android 优雅封装Glide
  • SprinBoot+Vue校园数字化图书馆系统的设计与实现
  • Oracle高级压缩和透明数据加密组合实验
  • 读软件设计的要素05概念的特性
  • 基于STM32设计的智能安防系统(微信小程序)(218)
  • linux学习之线程
  • Linux网络编程IO管理
  • JLabel设置字体大小颜色背景色
  • Go语言结构体和元组全面解析
  • 代码随想录八股训练营第三十三天| C++
  • 火狐浏览器设置秘籍:让https协议下的ws不加密时运行无阻(WebSocket connection HTTPS)
  • 【个人笔记】VCS工具与命令
  • HashMap中常用的函数
  • SPEC CPU2017的runcpu命令使用
  • Einsum(Einstein summation convention)
  • 30天pandas挑战
  • 中央纪委办公厅公开通报3起整治形式主义为基层减负典型问题
  • 最高法专门规范涉企案件审执工作:从源头防止趋利性执法司法
  • 著名统计学家、北京工业大学应用数理学院首任院长王松桂逝世
  • 单位被裁定补缴12年社保,滞纳金该谁出?
  • 经济日报:上海车展展现独特魅力
  • 广汽集团一季度净亏损7.3亿元,同比转亏,总销量下滑9%