Skip to content

Instantly share code, notes, and snippets.

@jakebresnehan
Forked from KuraFire/rgbaa.scss
Created September 19, 2012 09:19
Show Gist options
  • Save jakebresnehan/3748648 to your computer and use it in GitHub Desktop.
Save jakebresnehan/3748648 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