AI CSS Animations

3D Spinning Text

The word spins a full turn on its vertical axis, slowing at the front and at the back so both faces stay readable. The back face is a darker copy, and a floor shadow narrows as it turns edge-on.

Also known as: 3d rotating text css, rotate text 360 css, text spin animation.

HTML

<div class="txt-3d-spinning-text" aria-label="ORBIT"><span class="txt-3d-spinning-text-spin" aria-hidden="true"><span class="txt-3d-spinning-text-front">ORBIT</span><span class="txt-3d-spinning-text-back">ORBIT</span></span></div>

CSS

.txt-3d-spinning-text {
  --c: var(--txt-color, #3b82f6);
  font-size: calc(var(--txt-size, 32px) * 1.7);
  font-family: system-ui, sans-serif;
  font-weight: 900;
  line-height: 1.2;
  position: relative;
  display: inline-grid;
  perspective: 10em;
  color: var(--c);
  letter-spacing: 0.04em;}
.txt-3d-spinning-text::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -0.18em;
  height: 0.14em;
  border-radius: 50%;
  background: color-mix(in srgb, var(--c) 30%, transparent);
  filter: blur(0.04em);
  animation: txt-3d-spinning-text-shadow 3.6s infinite;
}
.txt-3d-spinning-text-spin {
  display: grid;
  transform-style: preserve-3d;
  animation: txt-3d-spinning-text-turn 3.6s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
.txt-3d-spinning-text-front,
.txt-3d-spinning-text-back {
  grid-area: 1 / 1;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.txt-3d-spinning-text-back {
  transform: rotateY(180deg);
  color: color-mix(in srgb, var(--c) 62%, #000);
}
/* Two eased halves: it slows down facing front, then facing back. */
@keyframes txt-3d-spinning-text-turn {
  0%   { transform: rotateY(0deg); }
  50%  { transform: rotateY(180deg); }
  100% { transform: rotateY(360deg); }
}
@keyframes txt-3d-spinning-text-shadow {
  0%, 50%, 100% { transform: scaleX(1); animation-timing-function: cubic-bezier(0.6, 0, 1, 0.5); }
  25%, 75%      { transform: scaleX(0.2); animation-timing-function: cubic-bezier(0, 0.5, 0.4, 1); }
}

@media (prefers-reduced-motion: reduce) {
  .txt-3d-spinning-text, .txt-3d-spinning-text *, .txt-3d-spinning-text::before, .txt-3d-spinning-text::after, .txt-3d-spinning-text *::before, .txt-3d-spinning-text *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

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