轨道环绕
Orbital Motion
小元素沿可见的轨道围绕固定中心转动。
适用场景
围绕中心展示关联图标,或说明物体的轨道。 当多个移动对象都围绕同一个参照物时,固定中心有助于读者看清它们之间的关系。
应用示例
天文课件中,学生点播放就能看到月球围绕固定的行星转动。轨道和两个标注一直清楚可见,便于对照月球所在的位置。
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;
}
.orbit-center {
width: 42px; aspect-ratio: 1; border-radius: 50%;
background: radial-gradient(circle at 35% 30%, #fff6c7, #f1b071 52%, #a84646);
box-shadow: 0 0 15px #f8a8574f;
}
.orbit-rail { position: absolute; width: 93px; aspect-ratio: 1; border: 1px dashed #b28fb1; border-radius: 50%; }
.orbit-arm { position: absolute; inset: 0; animation: orbit 4.8s linear infinite; }
.orbit-arm span {
position: absolute; top: 0; left: 50%; transform: translate(-50%, -50%);
width: 12px; aspect-ratio: 1; border-radius: 50%; background: #d8c6ff; box-shadow: 0 0 11px #c4abff;
}
@keyframes orbit { to { transform: rotate(360deg); } }
.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="orbit-center"></div><div class="orbit-rail"><div class="orbit-arm" data-motion><span></span></div></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 原创示例