跳动加载圆点
Bouncing Loading Dots
三个圆点依次跳动,提示等待或正在输入。
适用场景
用于聊天中的输入提示,或空间较小的行内加载状态。 让圆点占据下一条内容即将出现的小块空间,收到内容时就撤掉等待提示。
应用示例
客服正在输入时,聊天窗口在客服一侧放一个小气泡,里面三个圆点依次跳动。收到回复后,位置上换成客服发来的消息。
AI 提示词
在【状态区域】加入跳动加载圆点。相邻圆点延迟约 130 毫秒,保持容器宽度稳定,并提供一条屏幕阅读器可读的状态说明。
示例代码
保存为 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;
}
.example { width: min(100%, 228px); position: relative; display: grid; gap: 10px; }
.panel { background: #292240; border: 1px solid #675785; border-radius: 11px; padding: 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.label { margin: 0; font-size: 13px; font-weight: 650; }
.detail, .caption { margin: 0; color: #d7cbea; font-size: 11px; line-height: 1.35; }
.caption { text-align: center; }
.control { border: 1px solid #8874ae; background: #392e57; border-radius: 7px; padding: 5px 9px; min-height: 32px; color: #f6efff; cursor: pointer; font-size: 11px; font-weight: 650; }
.control:hover { background: #514174; }
.control.primary { color: #261b3f; background: #d1bfff; border-color: #e3d8ff; }
.control.primary:hover { background: #e3d8ff; }
.control:disabled { opacity: .55; cursor: default; }
.field { width: 100%; min-width: 0; padding: 6px 8px; border: 1px solid #875fa8; border-radius: 6px; color: #f6efff; background: #1e1732; font-size: 12px; }
.field::placeholder { color: #c2abd8; }
[hidden] { display: none !important; }
.loading { min-height: 80px; display: grid; gap: 8px; place-items: center; }
.indicator { display: flex; justify-content: center; align-items: center; }
.loading-ring .indicator { width: 28px; height: 28px; border: 3px solid #6d568c; border-top-color: #edd6ff; border-radius: 50%; animation: spin .8s linear infinite; }
.loading-dots .indicator { gap: 7px; min-height: 28px; }
.loading-dots i { width: 8px; height: 8px; border-radius: 50%; background: #edd6ff; animation: bounce 1s ease-in-out infinite; }
.loading-dots i:nth-child(2) { animation-delay: .13s; }
.loading-dots i:nth-child(3) { animation-delay: .26s; }
.loading-bar .indicator { position: relative; display: block; width: 78%; height: 5px; overflow: hidden; border-radius: 5px; background: #584674; }
.loading-bar .indicator::after { content: ''; display: block; width: 40%; height: 100%; border-radius: inherit; background: #e6cdfb; animation: sweep 1s ease-in-out infinite; }
.loading:not([data-active]) :is(.indicator, i), .loading:not([data-active]) .indicator::after { animation-play-state: paused; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce { 0%, 65%, 100% { opacity: .5; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-7px); } }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@media (prefers-reduced-motion: reduce) {
.example *, .example *::before, .example *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
</style>
</head>
<body>
<main class="demo">
<div class="example"><div class="panel loading loading-dots" data-active><span class="indicator" aria-hidden="true"><i></i><i></i><i></i></span><p class="detail" role="status">正在加载</p></div><div class="actions"><button class="control" type="button">暂停</button></div></div>
</main>
<script>
const panel = document.querySelector('.loading');
const state = panel.querySelector('[role="status"]');
const button = document.querySelector('button');
button.addEventListener('click', () => {
const active = panel.toggleAttribute('data-active');
button.textContent = active ? "暂停" : "继续";
state.textContent = active ? "正在加载" : "已暂停";
});
</script>
</body>
</html>UI Skills 原创示例