您的位置:首页 > Web前端 > CSS

css中png图片透明效果失效问题。

2014-06-09 14:41 381 查看
在元来的css中top .logo{ float:left;height:130px; width:560px; margin-top:20px; background:url(../image/aiyunlogo1.png)}我的logo图片css是这样写的,但是在ie浏览器中是不透明的,怎么弄呢。
改为这样!
.top .logo{ float:left;height:130px; width:560px; margin-top:20px; background:url(../image/aiyunlogo1.png)!important;background-repeat:no-repeat; _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="view/default/image/aiyunlogo1.png"); }
也就是说使用ie的滤镜来是png图片透明 ,

中途又出现问题,在别的pc用ie访问的时候,有阴影,原因是什么呢 原因是_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="view/default/image/aiyunlogo4.png",);最前面的下横杠。记住了 。当然百度了一下,在head里面放这个也可以
以下为引用的内容:
<script language="javascript">
function correctPNG()
{
for(var i=0; i<document.images.length; i++)
{
var img = document.images[i]
var imgName = img.src.toUpperCase()
if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
{
var imgID = (img.id) ? "id='" + img.id + "' " : ""
var imgClass = (img.className) ? "class='" + img.className + "' " : ""
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
var imgStyle = "display:inline-block;" + img.style.cssText
if (img.align == "left") imgStyle = "float:left;" + imgStyle
if (img.align == "right") imgStyle = "float:right;" + imgStyle
if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
var strNewHTML = "<span " + imgID + imgClass + imgTitle
+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
img.outerHTML = strNewHTML
i = i-1
} //LIEHUO.NET
}
}
window.attachEvent(" correctPNG);
</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  important