Skip to content

Instantly share code, notes, and snippets.

@benjamincharity
Created January 20, 2014 21:39
Show Gist options
  • Save benjamincharity/8529731 to your computer and use it in GitHub Desktop.
Save benjamincharity/8529731 to your computer and use it in GitHub Desktop.
Avoid using a light text color over certain background colors. http://sassbin.com/gist/8529640/
@function checkLightness($color) {
@if ( (lightness($color) > 70) or (hue($color) > 40 and hue($color) < 200 )) {
@return #000000;
}
@else {
@return #FFFFFF;
}
}
$myColor: green;
div {
background-color: $myColor;
color: checkLightness($myColor);
content: "HUE:#{hue($myColor)} - LIGHTNESS:#{lightness($myColor)}";
padding: .4em;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment