首页 前端知识 【CSS】如何写渐变色文字并且有打光效果

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

2024-09-28 23:09:23 前端知识 前端哥 766 465 我要收藏

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

 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>

转载请注明出处或者链接地址:https://www.qianduange.cn//article/18635.html
标签
评论
发布的文章

数据持久化(Json)

2024-09-28 23:09:01

JSON Gate 开源项目教程

2024-09-28 23:09:00

【C 】Ubuntu安装jsoncpp

2024-09-28 23:09:58

http请求json

2024-09-28 23:09:58

JSON 格式详解

2024-09-28 23:09:53

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!