Last active
December 29, 2015 20:39
-
-
Save stormwarning/7725427 to your computer and use it in GitHub Desktop.
Generate a colour value from an RGBa value.
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
/** | |
* A very simple, pragmatic Sass mixin for generating any property with an rgba() colour | |
* and its associated fallback (sourced from the original rgba() colour). | |
* | |
* Do not use if you require a fallback vastly different from the rgba(). | |
* | |
* 1. Strip the alpha value and write out a solid rgb() color. | |
* 2. Drop the red, green, blue, and alpha paramaters into the relevant places. | |
* | |
h1 { | |
@include rgba(color, 255, 0, 0, 0.5) | |
} | |
* | |
* @link: http://jsfiddle.net/csswizardry/h3eG8/ | |
*/ | |
@mixin rgba($property, $red, $green, $blue, $alpha) { | |
#{$property}: rgb(#{$red}, #{$green}, #{$blue}); /* [1] */ | |
#{$property}: rgba(#{$red}, #{$green}, #{$blue}, #{$alpha}); /* [2] */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment