sass兼容IE8透明度方法

你可以轻松的利用 {Sass::Script::Functions#ie_hex_str ie_hex_str} 函数对其做转换。
$translucent-red: rgba(255, 0, 0, 0.5); div { filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{ie-hex-str($translucent-red)}', endColorstr='#{ie-hex-str($translucent-red)}');

 经过检测,ie8下透明度为0.5时,此方法无效。究其原因:滤镜前段为7f,此方法转化为80。

另外小数点第二位未曾检测。

 

/* IE滤镜写法;

gradientType : 1代表水平方向 , 0 代表垂直线性渐变 ;

startColorstr是起始颜色,endColorstr是结束颜色;

颜色支持十六进制的写法或者英文单词 当然也支持透明度

[十六进制] #AAFF0000[AA是透明度(00是完全透明,FF是完全不透明)],后六位是标准的十六进制颜色写法;

*/ /*IE6~7*/

filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ccff7700", endColorstr="#eeccc222", GradientType=1);

/*IE8*/ -ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ccff7700", endColorstr="#eeccc222", GradientType=1);

 

posted @ 2016-03-23 15:25  没事看看电影  阅读(536)  评论(0编辑  收藏  举报