双层文字扫光效果

文字扫光效果

html 复制代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<title>Animated Shiny Text -- Correct</title>

<style>
  body {
    margin: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #0b0b0b;
    font-family: system-ui, -apple-system, BlinkMacSystemFont;
  }

  .shiny-wrapper {
    position: relative;
    font-size: 64px;
    font-weight: 700;
    line-height: 1.2;
  }

  /* 底层文字(永远可见) */
  .shiny-base {
    color: rgba(229, 231, 235, 0.7);
  }

  /* 上层扫光 */
  .shiny-overlay {
    position: absolute;
    inset: 0;
    color: transparent;

    background-image: linear-gradient(
      90deg,
      transparent,
      rgba(255, 255, 255, 0.9),
      transparent
    );
    background-repeat: no-repeat;
    background-size: 120px 100%;
    background-position: 0 0;

    -webkit-background-clip: text;
    background-clip: text;

    animation: shine 1.5s linear infinite;
    pointer-events: none;
  }

  @keyframes shine {
  from {
    background-position: -120% 0;
  }
  to {
    background-position: 220% 0;
  }
}
</style>
</head>

<body>

<div class="shiny-wrapper">
  <span class="shiny-base">Animate</span>
  <span class="shiny-overlay">Animate</span>
</div>

</body>
</html>
相关推荐
leobertlan3 小时前
2025年终总结
前端·后端·程序员
子兮曰4 小时前
OpenClaw架构揭秘:178k stars的个人AI助手如何用Gateway模式统一控制12+通讯频道
前端·javascript·github
百锦再4 小时前
Reactive编程入门:Project Reactor 深度指南
前端·javascript·python·react.js·django·前端框架·reactjs
莲华君4 小时前
React快速上手:从零到项目实战
前端·reactjs教程
百锦再4 小时前
React编程高级主题:测试代码
android·前端·javascript·react.js·前端框架·reactjs
易安说AI4 小时前
Ralph Loop 让Claude无止尽干活的牛马...
前端·后端
颜酱6 小时前
图结构完全解析:从基础概念到遍历实现
javascript·后端·算法
失忆爆表症6 小时前
05_UI 组件库集成指南:Shadcn/ui + Tailwind CSS v4
前端·css·ui
小迷糊的学习记录6 小时前
Vuex 与 pinia
前端·javascript·vue.js
发现一只大呆瓜6 小时前
前端性能优化:图片懒加载的三种手写方案
前端·javascript·面试