css 边框流光效果

旋转流光

javascript 复制代码
// html
<div class="demo">
  <div class="demo-content">
    旋转流光
  </div>
</div>
------------------------------------------------------
// 样式
body {
  background-color: black;
}

:root {
  --outer-radius: 0.5rem;
  --border-size: 5px;
}

@property --border-gradient-angle {
  syntax: "<angle>";
  inherits: true;
  initial-value: 0turn;
}

.demo {
  background-image: conic-gradient(from var(--border-gradient-angle) at 50% 50%, transparent, #70ffaf 14%, transparent 17%);
  border-radius: var(--outer-radius);
  background-size: contain;
  padding: var(--border-size);
  animation: buttonBorderSpin 9s linear infinite 0ms;
  width: 300px;
  height: 200px;
}

@keyframes buttonBorderSpin {
  0% {
    --border-gradient-angle: 0turn;
  }

  100% {
    --border-gradient-angle: 1turn;
  }
}

.demo-content {
  width: 100%;
  height: 100%;
  background-color: black;
}

平移流光

javascript 复制代码
// html
<div class="demo2">
  <div class="demo2-content">
    平移流光
  </div>
</div>
----------------------------------------------------------------
// 样式
:root {
  --outer-radius: 0.5rem;
  --border-size: 5px;
}

@property --border-gradient-angle {
  syntax: "<angle>";
  inherits: true;
  initial-value: 0turn;
}
.demo {
  margin-top: 10px;
  height: 50px;
  width: 300px;
  background-image: conic-gradient(from var(--border-gradient-angle) at 30% -30%, transparent 25%, #70ffaf 75%, transparent);
  animation: badgeBorderSpin 10s linear infinite;
  border-radius: var(--outer-radius);
  padding: var(--border-size);
}

@keyframes badgeBorderSpin {
  0% {
    --border-gradient-angle: 0turn;
  }

  100% {
    --border-gradient-angle: -1turn;
  }
}

.demo-content {
  width: 100%;
  height: 100%;
  background-color: black;
}
相关推荐
AI浩1 天前
【Labelme数据操作】LabelMe标注批量复制工具 - 完整教程
运维·服务器·前端
涔溪1 天前
CSS 网格布局(Grid Layout)核心概念、基础语法、常用属性、实战示例和进阶技巧全面讲解
前端·css
2401_878454531 天前
浏览器工作原理
前端·javascript
西陵1 天前
为什么说 AI 赋能前端开发,已经不是选择题,而是必然趋势?
前端·架构·ai编程
by__csdn1 天前
Vue3 setup()函数终极攻略:从入门到精通
开发语言·前端·javascript·vue.js·性能优化·typescript·ecmascript
天天扭码1 天前
前端如何实现RAG?一文带你速通,使用RAG实现长期记忆
前端·node.js·ai编程
Luna-player1 天前
在前端中,<a> 标签的 href=“javascript:;“ 这个是什么意思
开发语言·前端·javascript
lionliu05191 天前
js的扩展运算符的理解
前端·javascript·vue.js
小草cys1 天前
项目7-七彩天气app任务7.4.2“关于”弹窗
开发语言·前端·javascript
奇舞精选1 天前
GELab-Zero 技术解析:当豆包联手中兴,开源界如何守住端侧 AI 的“最后防线”?
前端·aigc