Last active
April 17, 2026 22:07
-
-
Save widoz/ac57fa86a71944615976ea617ee3e457 to your computer and use it in GitHub Desktop.
Render the underline border with loop animation on hover
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
| /* | |
| * Usage | |
| * | |
| * ``` | |
| * a { | |
| * @include mixins.animate-border-bottom-on-hover-loop(); | |
| * } | |
| * ``` | |
| */ | |
| @mixin animate-border-bottom-on-hover-loop() { | |
| position: relative; | |
| &::before { | |
| content: ''; | |
| position: absolute; | |
| bottom: 0; | |
| left: 0; | |
| height: 1px; | |
| border-bottom: 1px solid currentColor; | |
| } | |
| &::after { | |
| content: ''; | |
| position: absolute; | |
| bottom: 0; | |
| left: auto; | |
| right: 0; | |
| width: 100%; | |
| height: 1px; | |
| border-bottom: 1px solid currentColor; | |
| } | |
| &:hover { | |
| &::before { | |
| animation: by-zero-to-full-width var(--wp--custom--transition--duration) ease-out var(--wp--custom--transition--duration) both; | |
| } | |
| &::after { | |
| animation: by-full-width-to-zero var(--wp--custom--transition--duration) ease-in both; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment