A chomping Pac-Man eats a trail of dots that drift toward its mouth. Two rotating half-circles and three fading dots, all CSS.
Also known as: pacman animation, chomping loader.
<div class="ldr-pacman" role="status" aria-label="Loading"> <span></span><span></span><span></span> </div>
.ldr-pacman {
--s: var(--ldr-size, 48px);
--c: var(--ldr-color, #3b82f6);
position: relative;
width: calc(var(--s) * 2);
height: var(--s);
}
.ldr-pacman::before,
.ldr-pacman::after {
content: "";
position: absolute;
left: 0;
width: var(--s);
height: calc(var(--s) / 2);
background: var(--c);
}
.ldr-pacman::before {
top: 0;
border-radius: var(--s) var(--s) 0 0;
transform-origin: 50% 100%;
animation: ldr-pacman-top 0.5s ease-in-out infinite alternate;
}
.ldr-pacman::after {
top: 50%;
border-radius: 0 0 var(--s) var(--s);
transform-origin: 50% 0;
animation: ldr-pacman-bottom 0.5s ease-in-out infinite alternate;
}
.ldr-pacman span {
position: absolute;
top: calc(50% - var(--s) / 12);
right: 0;
width: calc(var(--s) / 6);
height: calc(var(--s) / 6);
border-radius: 50%;
background: color-mix(in srgb, var(--ldr-color, #3b82f6) 55%, transparent);
animation: ldr-pacman-dot 1.5s linear infinite;
}
.ldr-pacman span:nth-child(2) { animation-delay: -0.5s; }
.ldr-pacman span:nth-child(3) { animation-delay: -1s; }
@keyframes ldr-pacman-top { to { transform: rotate(-35deg); } }
@keyframes ldr-pacman-bottom { to { transform: rotate(35deg); } }
@keyframes ldr-pacman-dot {
from { transform: translateX(0); opacity: 1; }
to { transform: translateX(calc(var(--s) * -0.9)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
.ldr-pacman, .ldr-pacman *, .ldr-pacman::before, .ldr-pacman::after {
animation-duration: 3s;
}
}--ldr-color on the element or a parent.
Currently previewing #3b82f6.--ldr-size. Every dimension in the snippet is
derived from it. Currently previewing 64px.animation shorthand.
Delays on the children are relative, so they keep their rhythm.role="status" and an
aria-label so screen readers announce the wait. The reduced-motion rule
at the end slows the animation for users who asked for less motion.