Last active
August 29, 2015 14:05
-
-
Save craigmdennis/8f6e3420f58f984a34b3 to your computer and use it in GitHub Desktop.
Better underlines using background linear gradients
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
// 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