Skip to content

Instantly share code, notes, and snippets.

@davidsekar
Last active July 29, 2016 21:37
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 davidsekar/585ec5459165277b4cb136bc3fe1fedb to your computer and use it in GitHub Desktop.
Save davidsekar/585ec5459165277b4cb136bc3fe1fedb to your computer and use it in GitHub Desktop.
Scss force get hex value for the provided colour
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
@function returnHexValue($color){
@debug $color;
@if $color == "white" {
@return "#fff";
}
@if $color == "black" {
@return "#000";
}
@return $color;
}
@function force-hex($color) {
@if type-of($color) == 'color' {
$hex: str-slice(ie-hex-str($color), 4);
@return unquote("\##{$hex}");
}
@return $color;
}
body{
color: force-hex(teal);
}
body {
color: #008080;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment