Skip to content

Instantly share code, notes, and snippets.

@Broxzier
Last active November 26, 2025 12:48
Show Gist options
  • Select an option

  • Save Broxzier/9107ad8e2407a37f62f8bf6d3b158c8e to your computer and use it in GitHub Desktop.

Select an option

Save Broxzier/9107ad8e2407a37f62f8bf6d3b158c8e to your computer and use it in GitHub Desktop.
CSS underline hover animation
a {
color: black;
text-decoration: none;
}
a {
position: relative;
display: inline-block;
}
a::after {
content: '';
position: absolute;
right: 0;
bottom: 0;
height: 1px;
width: 0;
background: currentColor;
transition: width 0.2s cubic-bezier(.55,0,.1,1);
}
a:hover::after {
left: 0;
right: auto;
width: 100%;
}
@Broxzier
Copy link
Author

Broxzier commented Oct 29, 2025

This works for all <a> elements, but you can add a class or other selector conditions for the last 3 blocks to make it work for specific ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment