Last active
August 29, 2015 14:03
-
-
Save yankeyhotel/ecec3b196886eab6b05f to your computer and use it in GitHub Desktop.
A LESS Mixin to convert hex color values to rgba color values.
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
.hex-to-rgba (@color, @alpha: 1) { | |
@hex-to-rgba-red: red(@color); | |
@hex-to-rgba-green: green(@color); | |
@hex-to-rgba-blue: blue(@color); | |
@rgba: rgba(@hex-to-rgba-red, @hex-to-rgba-green, @hex-to-rgba-blue, @alpha); | |
} | |
// How to use | |
.hex-color { | |
.hex-to-rgba (#ffffff, .5); | |
color: @rgba; | |
} | |
// output | |
// .hex-color { | |
// color: rgba(255, 255, 255, 0.5); | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated the variables by adding the prefix "hex-to-rgba-" so it won't overwrite any variables that might be named @red, @green, and @blue.