Created
September 24, 2019 23:38
-
-
Save xdmorgan/b9a5ce1b936734d75feff3a9db7073f6 to your computer and use it in GitHub Desktop.
Background-image style link underline (Sass mixin with defaults)
This file contains 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
// Sassified version of the approach discussed here... | |
// big up: https://eager.io/blog/smarter-link-underlines/ | |
@mixin underline($fg: #000, $bg: #fff, $size: 1px, $ink: 0.03em, $pos: 87%) { | |
background: linear-gradient($bg, $bg), linear-gradient($bg, $bg), | |
linear-gradient($fg, $fg); | |
background-size: 0.05em $size, 0.05em $size, $size $size; | |
background-repeat: no-repeat, no-repeat, repeat-x; | |
text-shadow: $ink 0 $bg, -$ink 0 $bg, ($ink * 2) 0 $bg, -($ink * 2) 0 $bg, | |
($ink * 3) 0 $bg, -($ink * 3) 0 $bg, ($ink * 4) 0 $bg, -($ink * 4) 0 $bg, | |
($ink * 5) 0 $bg, -($ink * 5) 0 $bg; | |
background-position: 0 $pos, 100% $pos, 0 $pos; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🔜 An animatable alternative using
text-decoration-thickness
&text-underline-offset