CSSAwwwards
+ Submit tool
animation

CSS Animated Underline on Hover

Sliding underline effect on links and nav items using CSS transform and pseudo-elements.

An animated underline on hover creates polish without being distracting. The technique uses a ::after pseudo-element as the underline, scaled to zero by default. On hover, it scales to full width. By toggling transform-origin between 'right' and 'left', the underline slides in from the left and exits to the right — a subtle directional detail that feels intentional.

Live CSS Editor
CSS
Preview
Edit CSS → see live previewTab = 2 spaces

Usage Note

Put the transition on the ::after default state, not the :hover state — this ensures both entry and exit animate. The transform-origin swap (right → left) makes the underline slide in from the left on hover and retract to the right on mouse-leave.

Tags
#underline#hover#animation#pseudo-element#link#nav
Share on XLinkedIn