AI CSS Animations

Envelope Open Hover Effect

An envelope whose flap swings open on hover, then the letter slides up out of the pocket. The flap drops behind the letter halfway through, and leaving plays the steps in reverse.

Also known as: envelope animation css, letter out of envelope, invitation card hover.

You're invited

HTML

<div class="hfx-envelope-open">
  <div class="hfx-envelope-open-back"></div>
  <div class="hfx-envelope-open-letter">
    <strong>You're invited</strong>
    <span></span>
    <span></span>
  </div>
  <div class="hfx-envelope-open-pocket"></div>
  <div class="hfx-envelope-open-flap"></div>
</div>

CSS

.hfx-envelope-open {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  position: relative;
  width: 11em;
  height: 6.2em;
  margin-top: 1.8em;
  perspective: 30em;
  font-family: system-ui, sans-serif;
  filter: drop-shadow(0 0.4em 0.5em color-mix(in srgb, var(--c) 25%, transparent));
}
.hfx-envelope-open-back,
.hfx-envelope-open-pocket,
.hfx-envelope-open-flap {
  position: absolute;
  inset: 0;
  border-radius: 0.4em;
}
.hfx-envelope-open-back {
  background: color-mix(in srgb, var(--c) 70%, #fff);
}
.hfx-envelope-open-letter {
  position: absolute;
  z-index: 1;
  top: 0.4em;
  left: 0.8em;
  right: 0.8em;
  height: 5em;
  padding: 0.8em 0.9em;
  border-radius: 0.3em;
  background: #fff;
  transition: transform 0.3s cubic-bezier(0.5, 0, 1, 1);
}
.hfx-envelope-open-letter strong {
  display: block;
  font-size: 0.85em;
  color: color-mix(in srgb, var(--c) 80%, #000);
}
.hfx-envelope-open-letter span {
  display: block;
  height: 0.3em;
  margin-top: 0.5em;
  border-radius: 1em;
  background: color-mix(in srgb, var(--c) 20%, transparent);
}
.hfx-envelope-open-letter span:last-child {
  width: 60%;
}
.hfx-envelope-open-pocket {
  z-index: 2;
  background: linear-gradient(color-mix(in srgb, var(--c) 22%, #fff), color-mix(in srgb, var(--c) 34%, #fff));
  clip-path: polygon(0 0, 50% 58%, 100% 0, 100% 100%, 0 100%);
}
.hfx-envelope-open-flap {
  z-index: 3;
  bottom: auto;
  height: 60%;
  border-radius: 0.4em 0.4em 0 0;
  background: linear-gradient(color-mix(in srgb, var(--c) 38%, #fff), color-mix(in srgb, var(--c) 50%, #fff));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.25s, z-index 0s 0.25s;
}
.hfx-envelope-open:hover .hfx-envelope-open-flap {
  z-index: 0;
  transform: rotateX(180deg);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), z-index 0s 0.2s;
}
.hfx-envelope-open:hover .hfx-envelope-open-letter {
  transform: translateY(-2.9em);
  transition: transform 0.5s cubic-bezier(0.3, 1.4, 0.5, 1) 0.3s;
}

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

Customizing this snippet

  • Color: set --hfx-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --hfx-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 hover effects