---
title: "解决IE8下png背景图滤器设置后颜色变深的问题"
author: "cloudstars"
date: "2015-05-08T15:52:19Z"
tags: []
categories: ["Web前端"]
slug: "ie8-png"
draft: false
lastmod: "2015-05-08T15:52:56Z"
id: 2209457
url: "https://cloudstars.iteye.com/blog/2209457"
---

需求：  一个工资条展示界面，需要加水印

 

实现方法：在工资条的上面浮动一个DIV，设置DIV的背景为png的水印图片，同时设置DIV的透明度为60%

 

源代码：

&lt;div class="salary-data" style="height:300px;"&gt;  
  &lt;div class="salary-watermark"&gt;&lt;/div&gt;

    ....

  &lt;/div&gt;

&lt;/div&gt;

 

div.salary-data {  
 position: relative;  
 margin-top: 20px;

 min-height: 300px;  
}  
div.salary-watermark {  
 position: absolute;  
 top: 0;  
 left: 120px;  
 width: 474px;  
 height: 250px;  
 background: url(images/watermark.png) no-repeat center center;  
 opacity: 0.6;  
 filter: alpha(opacity=60);  
 zoom: 1;  
}

 

结果：

 

IE9/IE10/IE11下（无论哪种模式）的显示效果（显示正常）  
![](http://dl2.iteye.com/upload/attachment/0108/4311/825c65cd-80f7-3631-b127-5d7bb7085e58.png)

 

IE8下（无论哪种模式）的显示效果（显示不正常，颜色太黑）  
![](http://dl2.iteye.com/upload/attachment/0108/4341/18f2561e-8abe-360e-bb37-4ccf27425287.png)  
 

 **解决方法：**在浮动的DIV的 filter: alpha(opacity=60);设置后增加一个如下的CSS设置，增加后显示都正常了

 filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true);

 

修改后的浮动DIV的CSS

div.salary-watermark {  
 position: absolute;  
 top: 0;  
 left: 120px;  
 width: 474px;  
 height: 250px;  
 background: url(images/self/salary/watermark.png) no-repeat center center;  
 opacity: 0.6;  
 filter: alpha(opacity=60);  
 **filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true);**  
 zoom: 1;  
}