AI CSS Animations

Data Lock Secure

A padlock in front of an isometric data block snaps its shackle shut on a spring, then an accent perimeter ring settles around both. Hairline SVG with CSS translate and scale.

Also known as: security lock animation, encryption animation, hairline isometric.

HTML

<div class="hln-data-lock" role="img" aria-label="A data block being locked and secured">
  <svg viewBox="-110 -60 220 120" aria-hidden="true"><g transform="translate(0 14) scale(1.45)"><defs><clipPath id="hln-data-lock-clip"><polygon points="-26,-6 -8,3 -8,-90 -26,-90"/></clipPath></defs><path class="hln-data-lock-ring hln-data-lock-back" d="M-37.36 1A35.36 17.68 0 0 1 33.36 1"/><g><polygon points="-24,0 0,12 0,-10 -24,-22"/><polygon points="24,0 0,12 0,-10 24,-22"/><polygon points="0,-34 24,-22 0,-10 -24,-22"/></g><line class="hln-data-lock-in" x1="-24" y1="-7.5" x2="0" y2="4.5"/><line class="hln-data-lock-in" x1="24" y1="-7.5" x2="0" y2="4.5"/><line class="hln-data-lock-in" x1="-24" y1="-14.5" x2="0" y2="-2.5"/><line class="hln-data-lock-in" x1="24" y1="-14.5" x2="0" y2="-2.5"/><ellipse class="hln-data-lock-in" cx="-12" cy="-22" rx="3.11" ry="1.56"/><ellipse class="hln-data-lock-in" cx="0" cy="-22" rx="3.11" ry="1.56"/><ellipse class="hln-data-lock-in" cx="12" cy="-22" rx="3.11" ry="1.56"/><g><polygon points="-25,6.5 -13,12.5 -13,2.5 -25,-3.5"/><polygon points="-9,10.5 -13,12.5 -13,2.5 -9,0.5"/><polygon points="-21,-5.5 -9,0.5 -13,2.5 -25,-3.5"/></g><g clip-path="url(#hln-data-lock-clip)"><g class="hln-data-lock-shackle"><g transform="translate(-23 -4.5) matrix(1 0.5 0 1 0 0)"><path d="M2.5 2V-5.5A3.5 3.5 0 0 1 9.5 -5.5V2H8V-5.5A2 2 0 0 0 4 -5.5V2Z"/></g></g></g><g class="hln-data-lock-key" transform="translate(-19 4.3) matrix(1 0.5 0 1 0 0)"><circle cy="-0.7" r="1.3"/><path d="M-0.55 0H0.55L0.9 2.6H-0.9Z"/></g><path class="hln-data-lock-ring hln-data-lock-front" d="M33.36 1A35.36 17.68 0 0 1 -37.36 1"/></g></svg>
</div>

CSS

.hln-data-lock {
  --c: var(--hln-color, #ff4f2e);
  font-size: var(--hln-size, 16px);
  position: relative;
  display: grid;
  place-items: center;
  width: 22em;
  height: 12em;
  border-radius: 0.75em;
  background: #f6f5f1;
  overflow: hidden;
  --u: 1px;
}
.hln-data-lock svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: #ffffff;
  stroke: #1c1d21;
  stroke-width: 1.25;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.hln-data-lock svg * {
  vector-effect: non-scaling-stroke;
}
.hln-data-lock .hln-data-lock-in {
  stroke: #9a9ca3;
}
.hln-data-lock .hln-data-lock-shackle {
  translate: 0 calc(-5 * var(--u));
  animation: hln-data-lock-shackle 5.6s infinite;
}
.hln-data-lock .hln-data-lock-key {
  fill: #1c1d21;
  stroke: none;
}
.hln-data-lock .hln-data-lock-ring {
  fill: none;
  stroke: var(--c);
  opacity: 0;
  transform-box: fill-box;
  animation: hln-data-lock-ring 5.6s infinite;
}
.hln-data-lock .hln-data-lock-back {
  transform-origin: 50% 100%;
}
.hln-data-lock .hln-data-lock-front {
  transform-origin: 50% 0%;
}
@keyframes hln-data-lock-shackle {
  0% { translate: 0 calc(-5 * var(--u)); }
  8% { translate: 0 calc(-5 * var(--u)); animation-timing-function: cubic-bezier(0.3, 0, 0.2, 1); }
  15.7% { translate: 0 calc(0.4 * var(--u)); animation-timing-function: ease-in-out; }
  19.2% { translate: 0 calc(-0.1 * var(--u)); animation-timing-function: ease-in-out; }
  22% { translate: 0 0; }
  84% { translate: 0 0; animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1); }
  94% { translate: 0 calc(-5 * var(--u)); }
  100% { translate: 0 calc(-5 * var(--u)); }
}
@keyframes hln-data-lock-ring {
  0%, 22% { opacity: 0; scale: 1.25; animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1); }
  36%, 76% { opacity: 1; scale: 1; animation-timing-function: ease-in; }
  86%, 100% { opacity: 0; scale: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .hln-data-lock * {
    animation: none !important;
  }
  .hln-data-lock .hln-data-lock-shackle { translate: 0 0; }
  .hln-data-lock .hln-data-lock-ring { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .hln-data-lock, .hln-data-lock *, .hln-data-lock::before, .hln-data-lock::after, .hln-data-lock *::before, .hln-data-lock *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --hln-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --hln-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar hairline animations