Skip to content

Instantly share code, notes, and snippets.

@KuraFire
Created September 13, 2012 21:18
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save KuraFire/3717746 to your computer and use it in GitHub Desktop.
Save KuraFire/3717746 to your computer and use it in GitHub Desktop.
More dynamic, oldIE-compatible SCSS function for rgba
@function rgbaa($args...) {
// rgbaa(#FFF, .5)
@if length($args) == 2 {
$hex: nth($args, 1);
$alpha: nth($args, 2);
@if $oldIE == 1 {
@return rgb(red($hex), green($hex), blue($hex));
} @else {
@return rgba(red($hex), green($hex), blue($hex), $alpha);
}
// rgbaa(20, 30, 40, .5)
} @else if length($args) == 4 {
@if $oldIE == 1 {
@return rgb(nth($args, 1), nth($args, 2), nth($args, 3));
} @else {
@return rgba(nth($args, 1), nth($args, 2), nth($args, 3), nth($args, 4));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment