【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>
相关推荐
Cobyte21 分钟前
AI全栈实战:使用 Python+LangChain+Vue3 构建一个 LLM 聊天应用
前端·后端·aigc
NEXT0633 分钟前
前端算法:从 O(n²) 到 O(n),列表转树的极致优化
前端·数据结构·算法
剪刀石头布啊39 分钟前
生成随机数,Math.random的使用
前端
剪刀石头布啊40 分钟前
css外边距重叠问题
前端
剪刀石头布啊41 分钟前
chrome单页签内存分配上限问题,怎么解决
前端
剪刀石头布啊43 分钟前
css实现一个宽高固定百分比的布局的一个方式
前端
剪刀石头布啊1 小时前
js数组之快速组、慢数组、密集数组、稀松数组
前端
mango_mangojuice1 小时前
Linux学习笔记(make/Makefile)1.23
java·linux·前端·笔记·学习
Days20502 小时前
简单处理接口返回400条数据本地数据分页加载
前端
Novlan12 小时前
@tdesign/uniapp 图标瘦身
前端