Skip to content

Instantly share code, notes, and snippets.

@jensgro
Created February 28, 2013 14:16
Show Gist options
  • Save jensgro/5057045 to your computer and use it in GitHub Desktop.
Save jensgro/5057045 to your computer and use it in GitHub Desktop.
rgba-mixin that creates different code, depending on the envirnoment-variable "$isoldIE". If this variable is "true" only the filter for IE8 and before is printed. If the variable is "false" rgba-color is printed.
// 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);
@if $isoldIE == false {
background-color: $color; // fallback for old browser that are not oldIE - very seldom
background-color: $rgba;
} @else if $isoldIE == true {
background-color: transparent; // counteract against the defintion for older modern browsers
filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr='#{$ie-color}', EndColorStr='#{$ie-color}');
zoom: 1; // trigger hasLayout
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment