Sass in the Real World: book 2 of 4

Opacity Functions


Function defintion Function description
alpha($color) / opacity($color) Returns the opacity/alpha value of the color. This value ranges between 0 and 1 with 0.1 increments
Example:
$default-color: rgba(#cfa842, 0.7);
$opacity-value: alpha($default-color); // 0.7
$opacity-value: opacity($default-color); // 0.7
rgba($color, $alpha) Refer to color functions
Example:
opacify($color, $amount)/fade-in($color, $amount) These two functions increase the opacity value of a color by the given value. It takes a value between 0 and 1 in 0.1 increments.
Example:
opacify(rgba(#cfa842, 0.7), 0.1); //rgba(207, 168, 66, 0.8)
fade-in(rgba(#cfa842, 0.7), 0.2); //rgba(207, 168, 66, 0.9)
fade-out($color, $amount)/transparentize($color, $amount) These two functions decrease the opacity value of a color by the given value. It takes a value between 0 and 1 in 0.1 increments.
Example:
transparentize(rgba(#cfa842, 0.7), 0.1); //rgba(207, 168, 66, 0.6)
fade-out(rgba(#cfa842, 0.7), 0.2); //rgba(207, 168, 66, 0.5)