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

效果如上,其实核心除了渐变色文字的设置

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

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

完整代码

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

html 复制代码
<!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>
相关推荐
小小小小宇5 小时前
虚拟列表兼容老DOM操作
前端
悦悦子a啊5 小时前
Python之--基本知识
开发语言·前端·python
安全系统学习5 小时前
系统安全之大模型案例分析
前端·安全·web安全·网络安全·xss
涛哥码咖6 小时前
chrome安装AXURE插件后无效
前端·chrome·axure
OEC小胖胖6 小时前
告别 undefined is not a function:TypeScript 前端开发优势与实践指南
前端·javascript·typescript·web
行云&流水6 小时前
Vue3 Lifecycle Hooks
前端·javascript·vue.js
Sally璐璐6 小时前
零基础学HTML和CSS:网页设计入门
前端·css
老虎06277 小时前
JavaWeb(苍穹外卖)--学习笔记04(前端:HTML,CSS,JavaScript)
前端·javascript·css·笔记·学习·html
三水气象台7 小时前
用户中心Vue3网页开发(1.0版)
javascript·css·vue.js·typescript·前端框架·html·anti-design-vue
灿灿121387 小时前
CSS 文字浮雕效果:巧用 text-shadow 实现 3D 立体文字
前端·css