【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>

效果图

相关推荐
brzhang3 小时前
我操,终于有人把 AI 大佬们 PUA 程序员的套路给讲明白了!
前端·后端·架构
止观止4 小时前
React虚拟DOM的进化之路
前端·react.js·前端框架·reactjs·react
goms4 小时前
前端项目集成lint-staged
前端·vue·lint-staged
谢尔登4 小时前
【React Natve】NetworkError 和 TouchableOpacity 组件
前端·react.js·前端框架
Lin Hsüeh-ch'in4 小时前
如何彻底禁用 Chrome 自动更新
前端·chrome
augenstern4166 小时前
HTML面试题
前端·html
张可6 小时前
一个KMP/CMP项目的组织结构和集成方式
android·前端·kotlin
G等你下课6 小时前
React 路由懒加载入门:提升首屏性能的第一步
前端·react.js·前端框架
蓝婷儿7 小时前
每天一个前端小知识 Day 27 - WebGL / WebGPU 数据可视化引擎设计与实践
前端·信息可视化·webgl
然我7 小时前
面试官:如何判断元素是否出现过?我:三种哈希方法任你选
前端·javascript·算法