-
-
Save lunelson/7887317 to your computer and use it in GitHub Desktop.
HEX code Sass functions, normal and IE versions
This file contains 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
// ---- | |
// Sass (v3.3.0.rc.1) | |
// Compass (v0.13.alpha.10) | |
// ---- | |
@function baseten-hex($number) { | |
$hex-values: 0 1 2 3 4 5 6 7 8 9 a b c d e f; | |
@if round($number) != $number { | |
@warn "base10-hex() needs a integer"; | |
} | |
@if $number > 255 { | |
@warn "baseten-hex() numbers need to be less than or equal to 255" | |
} | |
@if $number < 0 { | |
@warn "baseten-hex() numbers need to be more than or equal to 0" | |
} | |
@return #{nth($hex-values, floor($number / 16) + 1)}#{nth($hex-values,((($number / 16) - floor($number / 16)) * 16) + 1)}; | |
} | |
@function iehex($color) { | |
$hex: opacify($color, 1); | |
$opacity: opacity($color); | |
$alpha: baseten-hex(round($opacity * 255)); | |
$red: baseten-hex(red($hex)); | |
$green: baseten-hex(green($hex)); | |
$blue: baseten-hex(blue($hex)); | |
@return unquote("##{$alpha}#{$red}#{$green}#{$blue}"); | |
} | |
$color: rgba(123,123,123,.8); | |
foo { | |
bar: iehex($color); | |
} |
This file contains 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
foo { | |
bar: #cc7b7b7b; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment