【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%;
  }
}
相关推荐
Irene199115 小时前
CSS 废弃属性分类总结
前端·css
青莲84315 小时前
Android 事件分发机制 - 事件流向详解
android·前端·面试
musashi15 小时前
用 Electron 写了一个 macOS 版本的 wallpaper(附源码、下载地址)
前端·vue.js·electron
满天星辰15 小时前
Typescript之类型总结大全
前端·typescript
JFChen15 小时前
Web 仔用 Node 像 Java 一样写后端服务
前端
XiaoSong16 小时前
React useState 原理和异步更新
前端·react.js
徐徐子16 小时前
从vue3 watch开始理解Vue的响应式原理
前端·vue.js
眯眼因为很困啦16 小时前
GitHub Fork 协作完整流程
前端·git·前端工程化
whisper16 小时前
🚀 React Router 7 + Vercel 部署全指南
前端