Skip to content

Instantly share code, notes, and snippets.

@i-like-robots
Created October 19, 2012 09:40
Show Gist options
  • Save i-like-robots/3917184 to your computer and use it in GitHub Desktop.
Save i-like-robots/3917184 to your computer and use it in GitHub Desktop.
LESS legacy IE transparent background colour
.ms-compatible-rgba-bg(@color, @alpha) {
// Lacking Sass' 'transparentize' function here =(
background-color:rgba( red(@color), green(@color), blue(@color), @alpha);
// Less can be very ugly, but using JS parsing is pretty useful
@alpha_rgb: 255 * @alpha;
@alpha_hex: ~`( parseInt("@{alpha_rgb}", 10)).toString(16)`;
@color_str: ~`"@{color}".replace('#', '')`;
*zoom:1;
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#@{alpha_hex}@{color_str}, endColorstr=#@{alpha_hex}@{color_str})";
*filter: ~"progid:DXImageTransform.Microsoft.gradient(startColorstr=#@{alpha_hex}@{color_str}, endColorstr=#@{alpha_hex}@{color_str})";
}
.omg-this-works-in-ie {
.ms-compatible-rgba-bg(#499EBB, .75);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment