Last active
November 26, 2025 12:48
-
-
Save Broxzier/9107ad8e2407a37f62f8bf6d3b158c8e to your computer and use it in GitHub Desktop.
CSS underline hover animation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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%; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.