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

效果图

相关推荐
华仔啊6 小时前
图片标签用 img 还是 picture?很多人彻底弄混了!
前端·html
lichong9516 小时前
XLog debug 开启打印日志,release 关闭打印日志
android·java·前端
烟袅6 小时前
作用域链 × 闭包:三段代码,看懂 JavaScript 的套娃人生
前端·javascript
风止何安啊7 小时前
收到字节的短信:Trae SOLO上线了?尝尝鲜,浅浅做个音乐播放器
前端·html·trae
抱琴_7 小时前
大屏性能优化终极方案:请求合并+智能缓存双剑合璧
前端·javascript
用户463989754327 小时前
Harmony os——长时任务(Continuous Task,ArkTS)
前端
fruge7 小时前
低版本浏览器兼容方案:IE11 适配 ES6 语法与 CSS 新特性
前端·css·es6
颜酱7 小时前
开发工具链-构建、测试、代码质量校验常用包的比较
前端·javascript·node.js
颜酱8 小时前
package.json 配置指南
前端·javascript·node.js
todoitbo8 小时前
基于 DevUI MateChat 搭建前端编程学习智能助手:从痛点到解决方案
前端·学习·ai·状态模式·devui·matechat