Skip to content

Instantly share code, notes, and snippets.

@jensgro
Last active December 14, 2015 07:18
Show Gist options
  • Save jensgro/5049331 to your computer and use it in GitHub Desktop.
Save jensgro/5049331 to your computer and use it in GitHub Desktop.
Converts a solid color with an alpha-channel-value into rgba and an IE-filter as fallback for oldIE (IE up to version 8).
// Converts a solid color with an alpha-channel-value into rgba
// and an IE-filter as fallback for oldIE (IE up to version 8)
@mixin all-rgba($color, $alpha) {
$rgba: rgba($color, $alpha);
$ie-color: ie-hex-str($rgba);
background-color: $color;
background-color: $rgba;
/* for oldIE */
*background-color: transparent;
filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr='#{$ie-color}', EndColorStr='#{$ie-color}');
zoom: 1;
}
.test {
@include all-rgba(rgb(162,0,0),0.2);
}
.test {
background-color: #a20000;
background-color: rgba(162, 0, 0, 0.2);
/* for oldIE */
*background-color: transparent;
filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr='#33A20000', EndColorStr='#33A20000');
zoom: 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment