用 --i 控制延迟,条目数量不固定也能用。
<ul class="st"><li style="--i:0">第一项</li><li style="--i:1">第二项</li><li style="--i:2">第三项</li><li style="--i:3">第四项</li></ul>.st { list-style: none; margin: 0; padding: 0; width: 180px; }
.st li {
padding: 9px 12px; margin-bottom: 6px;
background: #eef2ff; color: #1c3fd6;
border-radius: 8px;
font: 600 12px/1 -apple-system, sans-serif;
animation: rise .5s cubic-bezier(.2,.9,.3,1) both;
animation-delay: calc(var(--i) * 80ms);
}
@keyframes rise {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: none; }
}复制后可直接使用;如果要放进已有项目,注意把类名改成你项目里的命名,避免冲突。