【css酷炫效果】纯CSS实现按钮流光边框

【css酷炫效果】纯CSS实现按钮流光边框

【css酷炫效果】纯CSS实现按钮流光边框。

想直接拿走的老板,链接放在这里:https://download.csdn.net/download/u011561335/90490501

创作随缘,不定时更新。

创作背景

刚看到csdn出活动了,赶时间,直接上代码。

html结构

clike 复制代码
<!-- 结构示例 -->
<button class="glow-btn">
  流光按钮
  <span class="hover-effect"></span> <!-- 悬停特效层 -->
</button>

css样式

clike 复制代码
.glow-btn {
  /* 基础样式 */
  position: relative;
  padding: 16px 40px;
  border: none;
  background: #1a1a1a;
  color: #fff;
  font-size: 18px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}

/* 流光层 */
.glow-btn::before {
  content: '';
  position: absolute;
  left: -50%;
  top: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(
    #00ccff 0deg, 
    #7e00ff 90deg, 
    #ff0040 180deg, 
    #00ccff 360deg
  );
  animation: rotate 4s linear infinite;
  z-index: 0;
}

/* 遮罩层 */
.glow-btn::after {
  content: '';
  position: absolute;
  inset: 2px; /* 留出2px边框空间 */
  background: #1a1a1a;
  border-radius: 6px;
  z-index: 1;
}

/* 旋转动画 */
@keyframes rotate {
  100% { transform: rotate(360deg); }
}

/* 悬停速度变化 */
.glow-btn:hover::before {
  animation-duration: 2s;
}

/* 文字层 */ 
.glow-btn span {
  position: relative;
  z-index: 2;
}

完整代码

clike 复制代码
<!DOCTYPE html>
<style>
.glow-btn {
  /* 基础样式 */
  position: relative;
  padding: 16px 40px;
  border: none;
  background: #1a1a1a;
  color: #fff;
  font-size: 18px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}

/* 流光层 */
.glow-btn::before {
  content: '';
  position: absolute;
  left: -50%;
  top: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(
    #00ccff 0deg, 
    #7e00ff 90deg, 
    #ff0040 180deg, 
    #00ccff 360deg
  );
  animation: rotate 4s linear infinite;
  z-index: 0;
}

/* 遮罩层 */
.glow-btn::after {
  content: '';
  position: absolute;
  inset: 2px; /* 留出2px边框空间 */
  background: #f14545;
  border-radius: 6px;
  z-index: 1;
}

/* 旋转动画 */
@keyframes rotate {
  100% { transform: rotate(360deg); }
}

/* 悬停速度变化 */
.glow-btn:hover::before {
  animation-duration: 2s;
}

/* 文字层 */ 
.glow-btn span {
  position: relative;
  z-index: 2;
}
</style>

<button class="glow-btn">
  <span>环形流光</span>
</button>

</html>

效果图

相关推荐
南知意-8 分钟前
cloud-app-admin:一款现代化、开箱即用的 Vue 3 后台管理模板
前端·javascript·vue.js·开源·开源项目
前端小王呀12 分钟前
Vue 中高级开发面试题及答案
前端·javascript·vue.js
紫_龙13 分钟前
最新版vue3+TypeScript开发入门到实战教程之watch与watchEffect对比区别
前端·vue.js·typescript
啪叽14 分钟前
别再手写 if-else 选字体颜色了,CSS contrast-color() 来帮你处理
前端·css
刘宇琪33 分钟前
JavaScript单页应用(SPA)首次加载慢优化方案
前端
CoovallyAIHub34 分钟前
Agency-Agents(52k+ Stars):140+ 个角色模板,让 AI 编程助手变成一支专业团队
前端·算法·编程语言
德育处主任37 分钟前
前端元素转图片,dom-to-image-more入门教程
前端·javascript
伊可历普斯40 分钟前
前端数据校验太难?一个 Zod 就够了
前端·javascript
陈林梓41 分钟前
Axios 二次封装指南 & 跨系统复用建议
前端
ZoeLandia41 分钟前
基于 qiankun 的应用间页面跳转
前端·前端框架