Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.