Two dots speed toward each other, squash flat against the contact point, and fly apart again, with a faint shock ring at every hit. The squash is anchored on the side that touches.
Also known as: dot collision loader, bumping dots, two dots collide.
<div class="ldr-colliding-dots" role="status" aria-label="Loading"> <span style="--dir:-1"></span><span style="--dir:1"></span> </div>
.ldr-colliding-dots {
--s: var(--ldr-size, 48px);
--c: var(--ldr-color, #3b82f6);
--d: calc(var(--s) / 3.5);
position: relative;
width: calc(var(--s) * 1.5);
height: calc(var(--s) * 0.6);
}
.ldr-colliding-dots::after {
content: "";
position: absolute;
top: calc(50% - var(--d) * 0.6);
left: calc(50% - var(--d) * 0.6);
width: calc(var(--d) * 1.2);
height: calc(var(--d) * 1.2);
border: calc(var(--s) / 24) solid color-mix(in srgb, var(--ldr-color, #3b82f6) 45%, transparent);
border-radius: 50%;
opacity: 0;
animation: ldr-colliding-dots-shock 1.1s ease-out infinite;
}
.ldr-colliding-dots span {
position: absolute;
top: calc(50% - var(--d) / 2);
left: calc(50% - var(--d) / 2);
width: var(--d);
height: var(--d);
border-radius: 50%;
background: var(--c);
transform-origin: calc(50% - var(--dir) * 50%) 50%;
animation: ldr-colliding-dots-hit 1.1s infinite;
}
@keyframes ldr-colliding-dots-hit {
0%, 100% {
transform: translateX(calc(var(--dir) * var(--s) * 0.6)) scale(1, 1);
animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45);
}
42% {
transform: translateX(calc(var(--dir) * var(--d) / 2)) scale(1, 1);
animation-timing-function: ease-out;
}
50% {
transform: translateX(calc(var(--dir) * var(--d) / 2)) scale(0.7, 1.22);
animation-timing-function: ease-in-out;
}
58% {
transform: translateX(calc(var(--dir) * var(--d) / 2)) scale(1.06, 0.95);
animation-timing-function: cubic-bezier(0, 0.55, 0.45, 1);
}
}
@keyframes ldr-colliding-dots-shock {
0%, 44% { transform: scale(0.6); opacity: 0; }
48% { transform: scale(0.8); opacity: 1; }
75% { transform: scale(1.9); opacity: 0; }
100% { transform: scale(1.9); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
.ldr-colliding-dots, .ldr-colliding-dots *, .ldr-colliding-dots::before, .ldr-colliding-dots::after, .ldr-colliding-dots *::before, .ldr-colliding-dots *::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.