AI CSS Animations

Mail Between Two Houses

An accent envelope walks the dashed route from one hairline house down the street to its neighbor, the mailbox flag snaps up on arrival, and a reply makes the trip back.

Also known as: email animation, isometric house animation, send message animation, hairline animation.

HTML

<div class="hln-mail-houses" role="img" aria-label="An envelope travels between two houses and back"><svg viewBox="-56 -14.91 128 69.82" aria-hidden="true"><g><polygon points="-50,19 22,55 22,53.5 -50,17.5"/><polygon points="68,32 22,55 22,53.5 68,30.5"/><polygon points="-4,-5.5 68,30.5 22,53.5 -50,17.5"/></g><line x1="-36" y1="10.5" x2="36" y2="46.5" class="hln-mail-houses-l"/><line x1="-46" y1="15.5" x2="26" y2="51.5" class="hln-mail-houses-l"/><polyline points="-11,12 -27,20 17,42 33,34" fill="none" class="hln-mail-houses-l" stroke-dasharray="1.5 2.5"/><g><polygon points="-18,9 -2,17 -2,7 -18,-1"/><polygon points="12,10 -2,17 -2,7 12,0"/><polygon points="-4,-8 12,0 -2,7 -18,-1"/></g><polygon points="-4,-8 12,0 5,-2.5 -11,-10.5"/><polygon points="-18,-1 -2,7 5,-2.5 -11,-10.5"/><polygon points="12,0 -2,7 5,-2.5"/><polygon points="-12,10.5 -8,12.5 -8,6 -12,4"/><polygon points="-6.5,9.75 -3.5,11.25 -3.5,7.75 -6.5,6.25" class="hln-mail-houses-l"/><polygon points="-16.5,4.75 -13.5,6.25 -13.5,2.75 -16.5,1.25" class="hln-mail-houses-l"/><polygon points="9,6.5 5,8.5 5,5 9,3" class="hln-mail-houses-l"/><polygon points="4,9 1,10.5 1,7 4,5.5" class="hln-mail-houses-l"/><g><polygon points="26,31 42,39 42,29 26,21"/><polygon points="56,32 42,39 42,29 56,22"/><polygon points="40,14 56,22 42,29 26,21"/></g><polygon points="40,14 56,22 49,19.5 33,11.5"/><polygon points="26,21 42,29 49,19.5 33,11.5"/><polygon points="56,22 42,29 49,19.5"/><polygon points="32,32.5 36,34.5 36,28 32,26"/><polygon points="37.5,31.75 40.5,33.25 40.5,29.75 37.5,28.25" class="hln-mail-houses-l"/><polygon points="27.5,26.75 30.5,28.25 30.5,24.75 27.5,23.25" class="hln-mail-houses-l"/><polygon points="53,28.5 49,30.5 49,27 53,25" class="hln-mail-houses-l"/><polygon points="48,31 45,32.5 45,29 48,27.5" class="hln-mail-houses-l"/><line x1="20" y1="18.5" x2="20" y2="12.5"/><circle cx="20" cy="8.5" r="5"/><line x1="-13" y1="17" x2="-13" y2="12"/><g><polygon points="-16.2,12.4 -13.8,13.6 -13.8,11.2 -16.2,10"/><polygon points="-9.8,11.6 -13.8,13.6 -13.8,11.2 -9.8,9.2"/><polygon points="-12.2,8 -9.8,9.2 -13.8,11.2 -16.2,10"/></g><g transform="matrix(0 -1 1 -0.5 -13.2 12.1)"><g class="hln-mail-houses-flaga"><rect x="-0.4" y="0" width="0.8" height="3.6"/><rect x="-0.4" y="2.4" width="1.8" height="1.2"/></g></g><line x1="31" y1="39" x2="31" y2="34"/><g><polygon points="27.8,34.4 30.2,35.6 30.2,33.2 27.8,32"/><polygon points="34.2,33.6 30.2,35.6 30.2,33.2 34.2,31.2"/><polygon points="31.8,30 34.2,31.2 30.2,33.2 27.8,32"/></g><g transform="matrix(0 -1 1 -0.5 30.8 34.1)"><g class="hln-mail-houses-flagb"><rect x="-0.4" y="0" width="0.8" height="3.6"/><rect x="-0.4" y="2.4" width="1.8" height="1.2"/></g></g><g class="hln-mail-houses-env"><g class="hln-mail-houses-bob"><polygon points="-14.6,8.7 -9.4,11.3 -9.4,7.7 -14.6,5.1" class="hln-mail-houses-a"/><polyline points="-14.6,5.1 -12,8.5 -9.4,7.7" fill="none"/></g></g></svg></div>

CSS

.hln-mail-houses {
  --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-mail-houses svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: #ffffff;
  stroke: #1c1d21;
  stroke-width: 1.25;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.hln-mail-houses svg * {
  vector-effect: non-scaling-stroke;
}
.hln-mail-houses-l {
  stroke: #9a9ca3;
}
.hln-mail-houses-a {
  fill: var(--c);
}
.hln-mail-houses-env {
  animation: hln-mail-houses-env 8s linear infinite;
}
.hln-mail-houses-bob {
  animation: hln-mail-houses-bob 8s linear infinite;
}
.hln-mail-houses-flaga,
.hln-mail-houses-flagb {
  transform-origin: 0 0;
}
.hln-mail-houses-flaga {
  animation: hln-mail-houses-flaga 8s linear infinite;
}
.hln-mail-houses-flagb {
  animation: hln-mail-houses-flagb 8s linear infinite;
}
@keyframes hln-mail-houses-env {
  0%, 4% { transform: translate(calc(var(--u) * 0), calc(var(--u) * 0)); animation-timing-function: cubic-bezier(.65, 0, .35, 1); }
  11% { transform: translate(calc(var(--u) * -15), calc(var(--u) * 7.5)); animation-timing-function: cubic-bezier(.65, 0, .35, 1); }
  30% { transform: translate(calc(var(--u) * 29), calc(var(--u) * 29.5)); animation-timing-function: cubic-bezier(.65, 0, .35, 1); }
  38%, 54% { transform: translate(calc(var(--u) * 44), calc(var(--u) * 22)); animation-timing-function: cubic-bezier(.65, 0, .35, 1); }
  61% { transform: translate(calc(var(--u) * 29), calc(var(--u) * 29.5)); animation-timing-function: cubic-bezier(.65, 0, .35, 1); }
  80% { transform: translate(calc(var(--u) * -15), calc(var(--u) * 7.5)); animation-timing-function: cubic-bezier(.65, 0, .35, 1); }
  88%, 100% { transform: translate(calc(var(--u) * 0), calc(var(--u) * 0)); }
}
@keyframes hln-mail-houses-bob {
  0%, 38%, 54%, 88%, 100% { transform: translate(calc(var(--u) * 0), calc(var(--u) * 0)); }
  40%, 90% { transform: translate(calc(var(--u) * 0), calc(var(--u) * -1.2)); animation-timing-function: cubic-bezier(.3, 1.45, .5, 1); }
  44%, 94% { transform: translate(calc(var(--u) * 0), calc(var(--u) * 0)); }
}
@keyframes hln-mail-houses-flagb {
  0%, 38% { transform: rotate(0deg); animation-timing-function: cubic-bezier(.3, 1.45, .5, 1); }
  44%, 54% { transform: rotate(-90deg); animation-timing-function: cubic-bezier(.65, 0, .35, 1); }
  60%, 100% { transform: rotate(0deg); }
}
@keyframes hln-mail-houses-flaga {
  0% { transform: rotate(-90deg); animation-timing-function: cubic-bezier(.65, 0, .35, 1); }
  6%, 88% { transform: rotate(0deg); animation-timing-function: cubic-bezier(.3, 1.45, .5, 1); }
  94%, 100% { transform: rotate(-90deg); }
}
@media (prefers-reduced-motion: reduce) {
  .hln-mail-houses * {
    animation-play-state: paused !important;
    animation-delay: calc(var(--delay, 0s) - 3.8s) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hln-mail-houses, .hln-mail-houses *, .hln-mail-houses::before, .hln-mail-houses::after, .hln-mail-houses *::before, .hln-mail-houses *::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