An underline draws itself first, then the text rises out from behind it with a small overshoot. The wrapper's overflow: hidden ends at the line, so the text appears to come out of it.
Also known as: text reveal from line, underline then text animation, rise from behind line.
<div class="txt-text-rise-from-underline"><span class="txt-text-rise-from-underline-t">Now available</span></div>
.txt-text-rise-from-underline {
--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;
overflow: hidden;
padding: 0 0.1em 0.16em;
white-space: nowrap;
color: var(--c);}
.txt-text-rise-from-underline::after {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 0.08em;
border-radius: 0.04em;
background: var(--c);
transform-origin: 0 50%;
animation: txt-text-rise-from-underline-line 0.5s cubic-bezier(0.65, 0, 0.35, 1) both;
}
.txt-text-rise-from-underline-t {
display: inline-block;
animation: txt-text-rise-from-underline-rise 0.75s cubic-bezier(0.34, 1.35, 0.64, 1) 0.4s both;
}
@keyframes txt-text-rise-from-underline-line {
from { transform: scaleX(0); }
to { transform: scaleX(1); }
}
@keyframes txt-text-rise-from-underline-rise {
from { transform: translateY(120%); }
to { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
.txt-text-rise-from-underline, .txt-text-rise-from-underline *, .txt-text-rise-from-underline::before, .txt-text-rise-from-underline::after, .txt-text-rise-from-underline *::before, .txt-text-rise-from-underline *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--txt-color on the element or a parent.
Currently previewing #3b82f6.--txt-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 40px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.