Skip to content

Instantly share code, notes, and snippets.

@craigmdennis
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigmdennis/8f6e3420f58f984a34b3 to your computer and use it in GitHub Desktop.
Save craigmdennis/8f6e3420f58f984a34b3 to your computer and use it in GitHub Desktop.
Better underlines using background linear gradients
// Underlines
// http://codepen.io/ghepting/pen/tLnHK/
$background-color: #FFF;
$link-color: $grey-2;
$link-color-active: $brand-red;
$link-underline-color: $link-color;
$link-underline-color-active: $link-color-active;
$link-underline-width: 2px;
$link-underline-offset: 2px;
$breaking-underlines: true;
@mixin underline($color: $link-underline-color, $weight: $link-underline-width, $offset: $link-underline-offset) {
@if $breaking-underlines {
text-shadow:
-1px -1px 0 $background-color,
1px -1px 0 $background-color,
-1px 1px 0 $background-color,
1px 1px 0 $background-color;
}
background-image: linear-gradient(
to top,
transparent,
transparent $offset,
$color $offset,
$color ($offset + $weight),
transparent ($offset + $weight)
);
@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
background-image: linear-gradient(
to top,
transparent,
transparent $offset,
$color $offset,
$color ($offset + $link-underline-width/2),
transparent ($offset + $link-underline-width/2)
);
}
}
.content a {
@include underline();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment