Skip to content

Instantly share code, notes, and snippets.

@brandonferens
Created July 29, 2015 17:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonferens/ab2294e580e65644e596 to your computer and use it in GitHub Desktop.
Save brandonferens/ab2294e580e65644e596 to your computer and use it in GitHub Desktop.
// Sass's lighten function just adds the supplied percentage to the existing color's percentage
// making it really difficult to adjust a color's lightness in any sort of logical way. This
// function solves that issue increasing the percentage relative to the color's lightness.
@function lightenColor($color, $percentage) {
$diff: 100 - lightness($color); // Find the percentage difference
$quotient: $diff / 100%; // Dividing a percentage by a percentage return a decimal
$newPercentage: $quotient * $percentage;
@return lighten($color, $newPercentage);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment