Created
September 13, 2012 21:18
-
-
Save KuraFire/3717746 to your computer and use it in GitHub Desktop.
More dynamic, oldIE-compatible SCSS function for rgba
This file contains hidden or 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
@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