Skip to content

Instantly share code, notes, and snippets.

@englishextra
Forked from certainlyakey/library.scss
Created July 31, 2018 17:32
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 englishextra/3af2d4d1c5b0d89f4b88324d593b3cde to your computer and use it in GitHub Desktop.
Save englishextra/3af2d4d1c5b0d89f4b88324d593b3cde to your computer and use it in GitHub Desktop.
URL-encode color SASS function / convert color to hex SASS function
//does not work with colors containing alpha
@function encodecolor($string) {
@if type-of($string) == 'color' {
$hex: str-slice(ie-hex-str($string), 4);
$string:unquote("#{$hex}");
}
$string: '%23' + $string;
@return $string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment