在IE 11浏览器中无法使用灰度颜色

时间:2017-01-30 15:19:50

标签: html css internet-explorer grayscale

我希望在加载图像时显示灰色图像,当用户将鼠标悬停在图像上时,它应显示图像的原始颜色。

我试过下面的代码,它在Chrome浏览器中工作,但不能在IE浏览器中工作

CSS代码:



var data = [{"tags":["test","test2"]},{"tags":["test","test3"]}]

var result = data.reduce(function(r, e) {
  return (e.tags.forEach(e => r[e] = (r[e] || 0) + 1)), r
}, {})

console.log(result)

.testImage img {
    -webkit-filter: grayscale(100%);
    -moz-filter: grayscale(100%);
    -ms-filter: grayscale(100%);
    -o-filter: grayscale(100%);
    transition: filter 600ms ease;
    -webkit-transition: -webkit-filter 600ms ease;
    -o-transition: filter 600ms ease;
    -moz-transition: filter 600ms ease;
    -ms-transition: filter 600ms ease;

}

.testImage img:hover {
    -webkit-filter: grayscale(0%);
    filter: grayscale(0%);   
    -moz-filter: grayscale(0%);
    -ms-filter: grayscale(0%);
    -o-filter: grayscale(0%);
}




<div class="testImage"> <img title="Sample Title" src="http://www.w3schools.com/html/pic_mountain.jpg"> </div>https://jsfiddle.net/samalaraj72/ehu77xy7/1/

请帮我解决如何在IE浏览器中修复此问题

提前致谢。

1 个答案:

答案 0 :(得分:0)

尝试一下

if(this.company_id){
    this.getSamad(this.company_id);
    this.company = false;
} else if(this.policy_id){
    this.getSamad2(this.policy_id);
    this.company = false;
}