Skip to content

Instantly share code, notes, and snippets.

@dieppon
Created February 27, 2014 10:30
Show Gist options
  • Save dieppon/9247744 to your computer and use it in GitHub Desktop.
Save dieppon/9247744 to your computer and use it in GitHub Desktop.
Create cross-browsing alpha transparent backgrounds.
// RGBa background
@mixin background-rgba($color, $alpha) {
$rgba: rgba($color, $alpha);
$ie-hex-str: ie-hex-str($rgba);
// Fallback for web browsers that doesn't support RGBa
background-color: $color;
// Reset background to transparent only in IE 6-8 using the backslash 9 hack http://webdood.com/?p=57
background-color: transparent\9;
// RGBa with $alpha opacity
background-color: $rgba;
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#{$ie-hex-str},endColorstr=#{$ie-hex-str});
zoom: 1;
// Remove filter in IE9
&:nth-child(n) {
filter: none;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment