This may be Compass 101, but has anyone written a mixin which sets the alpha value of a color? Ideally, I would like the mixin to take any form of color definition, and apply transparency:
@include set-alpha( red, 0.5 ); //prints rgba(255, 0, 0, 0.5);
@include set-alpha( #ff0000, 0.5 ); //prints rgba(255, 0, 0, 0.5);
@include set-alpha( rgb(255,0,0), 0.5 ); //prints rgba(255, 0, 0, 0.5);
There's also ie-hex-str() for IE's ##AARRGGBB format:
I use the rgbapng compass plugin
Install
Usage
Compiles to:
From the documentation:
Use the
rgba
function built into SassCode: