【CSS】斜角流光样式

1. 效果图

代码实现

html 复制代码
<div class="flow-wrap">
  <div class="flow-box">斜角流光效果</div>
</div>
css 复制代码
.flow-wrap {
  position: relative;
  z-index: 1;
}
.flow-box {
  position: relative;
  width: 300px;
  height: 200px;
  background: #000;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  overflow: hidden;
  border-radius: 8px;
  margin: 0 auto;
}

.flow-box::before {
  content: '';
  position: absolute;
  width: 150%;
  height: 150%;
  background: linear-gradient(90deg, transparent, skyblue, transparent);
  animation: shine 3s linear infinite;
  transform: rotate(45deg);
}

@keyframes shine {
  0% {
    left: -100%;
    top: -100%;
  }
  30% {
    left: 100%;
    top: 100%;
  }
  100% {
    left: 100%;
    top: 100%;
  }
}
相关推荐
yinuo5 分钟前
轻松接入大语言模型API -04
前端
袋鼠云数栈UED团队1 小时前
基于 Lexical 实现变量输入编辑器
前端·javascript·架构
cipher1 小时前
ERC-4626 通胀攻击:DeFi 金库的"捐款陷阱"
前端·后端·安全
UrbanJazzerati1 小时前
非常友好的Vue 3 生命周期详解
前端·面试
AAA阿giao1 小时前
从零构建一个现代登录页:深入解析 Tailwind CSS + Vite + Lucide React 的完整技术栈
前端·css·react.js
兆子龙2 小时前
像 React Hook 一样「自动触发」:用 Git Hook 拦住忘删的测试代码与其它翻车现场
前端·架构
兆子龙3 小时前
用 Auto.js 实现挂机脚本:从找图点击到循环自动化
前端·架构
SuperEugene3 小时前
表单最佳实践:从 v-model 到自定义表单组件(含校验)
前端·javascript·vue.js
昨晚我输给了一辆AE863 小时前
为什么现在不推荐使用 React.FC 了?
前端·react.js·typescript
不会敲代码13 小时前
深入浅出 React 闭包陷阱:从现象到原理
前端·react.js