循环波浪
Animated Wave
弯曲的色带横向移动,像水面上的波浪一层层经过。
适用场景
让插画、音频封面或装饰性分隔带缓慢流动。 把移动的波浪边缘放在可以横向延伸的区域里,给标签和关键状态留出稳定空间。
应用示例
水族馆活动页用两层叠加的波浪把开放时间和展区列表隔开。色带以不同速度横移,上方的开放时间始终容易扫读。
AI 提示词
给【目标区域】加循环波浪。裁切两层较宽的曲线色带,用不同节奏横向移动。保证上方内容清晰可读,减少动态时显示固定波形。
示例代码
保存为 HTML 文件后,用浏览器打开即可运行。代码与页面里的演示一致。
查看 HTML
<!doctype html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>循环波浪</title>
<style>
:root {
color-scheme: dark;
--demo-bg: #171629;
--demo-ink: #f8f5ff;
--demo-accent: #b9a6ff;
--demo-muted: #bfbbd3;
font-family: system-ui, sans-serif;
color: var(--demo-ink);
background: var(--demo-bg);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
button, input { font: inherit; }
.demo {
display: grid;
place-items: center;
align-content: center;
min-height: 100vh;
padding: 14px;
overflow: hidden;
background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
}
.demo-button {
border: 1px solid #ffffff3d;
border-radius: 7px;
background: #ffffff12;
color: var(--demo-ink);
padding: 6px 11px;
font-size: 12px;
cursor: pointer;
}
:focus-visible {
outline: 2px solid var(--demo-accent);
outline-offset: 3px;
}
.wave { position: relative; overflow: hidden; width: min(100%, 235px); height: 96px; border-radius: 14px; background: #103646; }
.wave i {
position: absolute; top: 38%; left: -52%; width: 181%; height: 180%;
border-radius: 44%; background: #399aae;
animation: wave 4.4s ease-in-out infinite alternate;
}
.wave i:nth-child(2) { top: 52%; left: -34%; background: #74dfcd; animation-duration: 5.9s; animation-direction: alternate-reverse; }
@keyframes wave { to { transform: translateX(30%) translateY(-10px) rotate(12deg); } }
.motion-example { display: grid; justify-items: center; width: 100%; gap: 10px; }
.motion-specimen {
display: grid;
place-items: center;
width: min(100%, 295px);
height: 108px;
position: relative;
isolation: isolate;
}
.motion-example [data-motion] { animation-play-state: paused; }
.motion-example[data-playing] [data-motion] { animation-play-state: running; }
@media (prefers-reduced-motion: reduce) {
.motion-example [data-motion] { animation: none; }
.motion-example [data-loop-toggle] { display: none; }
}
</style>
</head>
<body>
<main class="demo">
<div class="motion-example">
<div class="motion-specimen" aria-hidden="true"><div class="wave"><i data-motion></i><i data-motion></i></div></div>
<button class="demo-button" type="button" data-loop-toggle data-testid="effect-demo-loop-toggle">播放演示</button>
</div>
</main>
<script>
const example = document.querySelector('.motion-example');
const toggle = example.querySelector('[data-loop-toggle]');
toggle.addEventListener('click', () => {
const playing = example.toggleAttribute('data-playing');
toggle.textContent = playing ? "暂停演示" : "播放演示";
});
</script>
</body>
</html>UI Skills 原创示例