Skip to content

Instantly share code, notes, and snippets.

@xdmorgan
Created September 24, 2019 23:38
Show Gist options
  • Save xdmorgan/b9a5ce1b936734d75feff3a9db7073f6 to your computer and use it in GitHub Desktop.
Save xdmorgan/b9a5ce1b936734d75feff3a9db7073f6 to your computer and use it in GitHub Desktop.
Background-image style link underline (Sass mixin with defaults)
// 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;
}
@xdmorgan
Copy link
Author

xdmorgan commented Sep 24, 2019

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