AI CSS Animations

Curtain Drop Button

A pleated curtain drops from the top, bounces twice off the bottom edge and settles. The bounce is a linear() easing curve, and the folds are one repeating gradient.

Also known as: curtain fill hover, roller blind button, drop down fill.

HTML

<button class="hfx-curtain-drop">Watch the demo</button>

CSS

.hfx-curtain-drop {
  --c: var(--hfx-color, #3b82f6);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.75em 1.75em;
  border-radius: 0.5em;
  font: 600 var(--hfx-size, 16px)/1.2 system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  border: 2px solid var(--c);
  background: transparent;
  color: var(--c);
  transition: color 0.2s ease 0.15s;
}
.hfx-curtain-drop::before {
  content: "";
  position: absolute;
  inset: -40% 0 0;
  z-index: -1;
  background:
    linear-gradient(to top, color-mix(in srgb, #000 18%, var(--c)) 0 0.14em, transparent 0),
    repeating-linear-gradient(90deg, color-mix(in srgb, #fff 10%, transparent), color-mix(in srgb, #000 10%, transparent) 0.7em, color-mix(in srgb, #fff 10%, transparent) 1.4em),
    var(--c);
  transform: translateY(-100%);
  transition: transform 0.35s cubic-bezier(0.5, 0, 0.75, 0);
}
.hfx-curtain-drop:is(:hover, :focus-visible) {
  background-color: var(--c); /* hides the hairline where the fill meets the border */
  color: #fff;
  transition: color 0.2s ease 0.2s, background-color 0s 0.8s;
}
.hfx-curtain-drop:is(:hover, :focus-visible)::before {
  transform: translateY(0);
  transition: transform 0.8s linear(0, 0.06 8.75%, 0.25 17.5%, 0.56 26.25%, 1 35%, 0.925 41%, 0.9 47%, 0.925 53%, 1 59%, 0.98 65%, 1 71%);
}

@media (prefers-reduced-motion: reduce) {
  .hfx-curtain-drop, .hfx-curtain-drop *, .hfx-curtain-drop::before, .hfx-curtain-drop::after, .hfx-curtain-drop *::before, .hfx-curtain-drop *::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