AI CSS Animations

Split Double Border Button

Two outlines sit exactly on top of each other and read as one. On hover they split apart diagonally into two colors with a springy overshoot. Two bordered pseudo-elements, and only transform moves.

Also known as: offset border button, double outline hover, misregistered print effect.

HTML

<button class="btn-double-border-split">View work</button>

CSS

.btn-double-border-split {
  --c: var(--btn-color, #3b82f6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  font: 600 var(--btn-size, 18px)/1.2 system-ui, sans-serif;
  cursor: pointer;
  --c2: color-mix(in srgb, var(--c) 45%, #d946ef);
  position: relative;
  padding: 0.8em 1.8em;
  border: 0;
  border-radius: 0.4em;
  background: transparent;
  color: var(--c);}
.btn-double-border-split::before,
.btn-double-border-split::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid var(--c2);
  border-radius: inherit;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-double-border-split::after { border-color: var(--c); }
.btn-double-border-split:is(:hover, :focus-visible)::before { transform: translate(0.3em, 0.3em); }
.btn-double-border-split:is(:hover, :focus-visible)::after { transform: translate(-0.3em, -0.3em); }

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

Customizing this snippet

  • Color: set --btn-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --btn-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 18px.
  • 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 buttons