DEV Community

Nureon
Nureon

Posted on

Animated text underline in CSS only

Animated underline

.animated-underline {
    position: relative;
    text-decoration: none;
}

.animated-underline::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    width: 100%;
    height: 0.125em;
    background-color: hsl(200deg, 100%, 50%);
    transition: transform 320ms ease;
    transform: translate(-50%, 0%) scaleX(0);
    transform-origin: right;
}

.animated-underline:hover::after {
    transform-origin: left;
    transform: translate(-50%, 0%) scaleX(1);
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay