YL

CARD

流光边框卡片Conic Border Card / Animated Gradient Border

一道 conic-gradient 光带沿着卡片边框转一圈,像一圈光流过;悬停或聚焦时再转一圈。

中英对照

中文
流光边框卡片
英文
Conic Border Card / Animated Gradient Border
别名
旋转边框、流光描边、动态渐变边框
一句话
一道 conic-gradient 光带沿着卡片边框转一圈,像一圈光流过;悬停或聚焦时再转一圈。

效果预览

AI Copilot 已就绪 一道光带沿着边框流过一圈——conic-gradient 加 @property 的旋转动画,悬停时再转一圈。

常见变体

暗色卡面流光Dark Conic Border

卡面换成近黑底,光带在深色背景上对比更强,更有「科技感」,适合 AI、开发者工具的首页卡片。

单色亮弧Single-color Arc

只让一小段弧发亮、其余透明,光带像一道扫过的流星;气质更克制,和流光边框按钮的写法更接近。

适合用在哪

AI 产品卡片、旗舰功能、新品发布;科技感拉满的强调手段。

不适合:同屏有多张卡片的列表页、需要长时间阅读的内容区,以及移动端低端机型的首屏:每张卡都在加载时转一圈,会同时触发多条 @property 动画,既吵眼又吃性能;这类场景用静态渐变描边卡,只给一张重点卡配流光。

和相近模式的区别

渐变描边卡片Gradient Border Card

渐变描边卡是静态线性渐变,零动画;流光边框卡片在同样的双层结构上加了 @property + conic-gradient,让整圈多色光带沿边转一圈(约 5 秒,只转一次),悬停或聚焦时再转一圈。需要稳妥强调用渐变描边,想要「刚出现就有一道光流过」的仪式感才换流光。

流光边框按钮Border Beam Button

原理相同(@property 注册角度 + conic-gradient 旋转),也都是加载时转一圈就停、悬停或聚焦时再转一圈;区别在用量:流光边框卡片是整圈多色渐变(色 A → B → C → A)铺满卡片四周,转一圈约 5 秒;流光边框按钮只让约 30% 的弧发亮、其余透明,3 秒转一圈,像一束光沿着按钮边跑过。

容易踩的坑

  • 同屏多张卡同时无限旋转,GPU 持续占用,笔记本风扇狂转、电池掉得快。
  • 改成无限循环却不提供暂停按钮、也不响应 prefers-reduced-motion,持续干扰阅读(违反 WCAG 2.2.2)。
  • 父元素未建立层叠上下文,z-index:-1 的伪元素跑到页面背景后面看不见。
  • 悬停转到一半就移开时,光带会跳回起点:这是 spin-replay 被移除、回到已播完那圈的终态,属于正常现象,不要为了消除它改回无限循环。

设计提示词 · Prompt

流光边框卡片(Animated Conic Gradient Border):先声明 @property --angle{syntax:"<angle>";initial-value:0deg;inherits:false}。卡片本体 position:relative;z-index:0,::before 铺满外扩 1.5px(inset:-1.5px)、border-radius 比卡片大 1.5px、background:conic-gradient(from var(--angle),色A,色B,色C,色A)、z-index:-1、animation:spin 5s linear 1(keyframes 把 --angle 转到 360deg),加载时只转一圈就停。再叠 ::after(inset:0、白底、圆角与卡片相同、z-index:-1)充当卡面,排在 ::before 之后会盖住渐变中间,只露出外扩的 1.5px 光边。:hover 与 :focus-within 时写成 animation:spin 5s linear 1, spin-replay 5s linear 1(spin-replay 是内容相同的另一组 keyframes),保留已播完的那圈、再追加一圈,移开时只移除 spin-replay,不会又转一圈。如果产品坚持无限循环,必须提供可见的暂停按钮(WCAG 2.2.2:自动播放超过 5 秒的移动内容必须可暂停);prefers-reduced-motion 时 animation:none,停在静态渐变边框。不支持 @property 的浏览器会静止显示渐变边框,属于优雅降级。
Animated Conic Gradient Border: first declare @property --angle{syntax:"<angle>";initial-value:0deg;inherits:false}. The card itself is position:relative;z-index:0; its ::before fills it with a 1.5px outward expansion (inset:-1.5px), a border-radius 1.5px larger than the card, background:conic-gradient(from var(--angle), color A, color B, color C, color A), z-index:-1, and animation:spin 5s linear 1 (keyframes rotate --angle to 360deg), so it turns once on load and stops. Then layer an ::after (inset:0, white background, the same border-radius as the card, z-index:-1) as the card face; coming after ::before, it covers the middle of the gradient and leaves only the 1.5px outward edge glowing. On :hover and :focus-within write animation:spin 5s linear 1, spin-replay 5s linear 1 (spin-replay is a second keyframes with the same content): the finished turn is kept and one more turn is appended, and moving away only removes spin-replay, so it does not spin again. If the product insists on an infinite loop, provide a visible pause button (WCAG 2.2.2: auto-playing motion longer than 5 seconds must be pausable); under prefers-reduced-motion use animation:none and keep a static gradient border. Browsers without @property support display a static gradient border, which is a graceful degradation.

可复制 CSS

自包含的最小实现,粘贴到空白页面即可生效;类名可以按项目规范改名。

/* <div class="conic-card"><b>实时协作</b><p>多人同时编辑,光标与评论即时同步。</p><a href="#">了解更多</a></div> */
@property --card-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}
.conic-card {
  position: relative;
  z-index: 0; /* 建立层叠上下文,负 z-index 的伪元素才不会掉到页面背景后面 */
  max-width: 320px;
  padding: 22px 24px;
  border-radius: 16px;
  color: #1f2937;
  font: 14px/1.6 system-ui, sans-serif;
}
.conic-card::before {
  content: "";
  position: absolute;
  inset: -1.5px;
  z-index: -1;
  border-radius: 17.5px;
  /* var 的兜底值让不支持 @property 的浏览器显示静态渐变边 */
  background: conic-gradient(from var(--card-angle, 0deg), #4f46e5, #06b6d4, #c026d3, #f59e0b, #4f46e5);
  animation: conic-spin 5s linear 1; /* 加载时只转一圈,不要默认 infinite */
}
/* 卡面:排在 ::before 之后,盖住渐变中间,只露出外扩的 1.5px 光边 */
.conic-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: #fff;
}
/* 保留已播完的那圈,再追加一圈 replay;移开只移除 replay,不会又转 */
.conic-card:hover::before,
.conic-card:focus-within::before {
  animation: conic-spin 5s linear 1, conic-spin-replay 5s linear 1;
}
@keyframes conic-spin { to { --card-angle: 360deg; } }
@keyframes conic-spin-replay { to { --card-angle: 360deg; } }
.conic-card b { display: block; margin-bottom: 4px; font: 650 16px/1.3 system-ui, sans-serif; }
.conic-card p { margin: 0 0 10px; color: #4b5563; }
.conic-card a { color: #4f46e5; font-weight: 600; }
.conic-card a:focus-visible { outline: 2px solid #4f46e5; outline-offset: 3px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  .conic-card::before,
  .conic-card:hover::before,
  .conic-card:focus-within::before { animation: none; }
}

演示 HTML 结构

<div class="s d-conic">
  <b>AI Copilot 已就绪</b>
  <span>一道光带沿着边框流过一圈——conic-gradient 加 @property 的旋转动画,悬停时再转一圈。</span>
</div>

无障碍与性能

无障碍

  • 只转一次的设计天然满足 WCAG 2.2.2(自动播放不超过 5 秒)的要求,所以默认不要改成 infinite;确实要持续旋转,就必须给出可见的暂停控件。
  • prefers-reduced-motion: reduce 时关闭全部 animation,停在静态渐变边框,视觉信息不变、只去掉运动。
  • 光边只是装饰,卡内文字与白色卡面对比度仍按 4.5:1 校核;键盘用户通过 :focus-within 同样能触发那一圈光,焦点环则画在卡内的链接或按钮上。

性能

  • @property 动画每帧都要在主线程重绘 conic-gradient(不是只靠合成器的 transform 动画),所以一次性 5 秒、同屏最多 1-2 张是合理上限。
  • 不要给 ::before 加 will-change 或 filter:blur 做柔光:会额外创建合成层,并让每帧重绘面积变大;需要光晕就另放一层静态的 box-shadow。
  • 长列表里改用 IntersectionObserver,卡片滚进视口时再加上触发类名,避免页面加载瞬间所有卡片一起转。

常见问题

流光边框卡片的英文是什么?

流光边框卡片的英文是 Conic Border Card / Animated Gradient Border。

Conic Border Card / Animated Gradient Border 的中文是什么?

Conic Border Card / Animated Gradient Border 的中文是「流光边框卡片」。常见中文别名还包括 旋转边框、流光描边、动态渐变边框。一道 conic-gradient 光带沿着卡片边框转一圈,像一圈光流过;悬停或聚焦时再转一圈。

为什么要写两组内容相同的 keyframes(spin 和 spin-replay)?

CSS 动画只有在 animation-name 列表变化时才会重新开始。悬停时把列表从 [spin] 变成 [spin, spin-replay],新增的 spin-replay 会从头播放,而 spin 已播完的终态保留;移开后列表又变回 [spin],replay 被移除、spin 仍是播完的状态,所以不会再转。只用一组 keyframes 做不到「保留一圈 + 追加一圈」。

浏览器不支持 @property 会怎样?

渐变本身仍然画得出来:var(--card-angle, 0deg) 的兜底值让它固定在 0° 起点,用户看到的是静止的多色渐变边框,只是不会旋转。这是优雅降级,不需要额外写 @supports;真正要注意的是不要依赖「转完这一圈」才能传达信息。

卡片不是白底(深色或渐变背景)时 ::after 怎么处理?

::after 的背景要改成与卡面一致的实色,深色卡直接换成 #12121A 一类的底色即可。如果卡面是半透明或渐变,盖一层实色会盖掉真实内容,这时改用 mask-composite 把渐变挖成环形,只保留 1.5px 的光边,卡面可以保持透明,但写法更复杂、兼容性略差。

常见搭配

同一页面里经常和「流光边框卡片」一起出现的模式,可以收藏后用「组合收藏为整页提示词」一起交给 AI。

所属设计风格

「流光边框卡片」是这些整体设计风格的常见组成部分,在设计风格词典里可以看到整页效果。

标签