AI CSS Animations

Reveal From Center Text Effect

A thin line grows at the center, splits in two, and the lines slide outward pulling the text open behind them. A clip-path inset and two border lines share one easing curve.

Also known as: text expand from center, center out text reveal, split line text reveal.

Grand opening

HTML

<div class="txt-reveal-from-center"><span class="txt-reveal-from-center-t">Grand opening</span></div>

CSS

.txt-reveal-from-center {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  position: relative;
  display: inline-block;
  padding: 0 0.25em;
  white-space: nowrap;
  color: var(--c);}
.txt-reveal-from-center-t {
  display: inline-block;
  clip-path: inset(0 50%);
  animation: txt-reveal-from-center-open 1.3s both;
}
/* each line lives in one half of the box and travels from the center to its edge */
.txt-reveal-from-center::before,
.txt-reveal-from-center::after {
  content: "";
  position: absolute;
  top: -0.12em;
  bottom: -0.12em;
  width: 50%;
  border: 0 solid var(--c);
}
.txt-reveal-from-center::before {
  left: 0;
  border-left-width: 0.06em;
  animation: txt-reveal-from-center-left 1.3s both;
}
.txt-reveal-from-center::after {
  right: 0;
  border-right-width: 0.06em;
  animation: txt-reveal-from-center-right 1.3s both;
}
@keyframes txt-reveal-from-center-open {
  0%, 30%   { clip-path: inset(0 50%); animation-timing-function: cubic-bezier(0.7, 0, 0.2, 1); }
  80%, 100% { clip-path: inset(0 0); }
}
@keyframes txt-reveal-from-center-left {
  0%   { opacity: 1; transform: translateX(100%) scaleY(0); animation-timing-function: cubic-bezier(0.3, 0, 0.2, 1); }
  30%  { transform: translateX(100%) scaleY(1); animation-timing-function: cubic-bezier(0.7, 0, 0.2, 1); }
  80%  { opacity: 1; transform: translateX(0) scaleY(1); }
  100% { opacity: 0; transform: translateX(0) scaleY(1); }
}
@keyframes txt-reveal-from-center-right {
  0%   { opacity: 1; transform: translateX(-100%) scaleY(0); animation-timing-function: cubic-bezier(0.3, 0, 0.2, 1); }
  30%  { transform: translateX(-100%) scaleY(1); animation-timing-function: cubic-bezier(0.7, 0, 0.2, 1); }
  80%  { opacity: 1; transform: translateX(0) scaleY(1); }
  100% { opacity: 0; transform: translateX(0) scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
  .txt-reveal-from-center, .txt-reveal-from-center *, .txt-reveal-from-center::before, .txt-reveal-from-center::after, .txt-reveal-from-center *::before, .txt-reveal-from-center *::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