十一月 9th, 2007

针对IE6不支持png

3,210位瞄过, 网事点滴, by ufo.

从所周知IE6是不支持png透明图,
这是我今天在komodomedia看见的一个较新的技术只用css文件就可以了,同时需要1px X 1px的透明gif.
这技术还不支持background-repeat.

/* pngfix.css */
* html img,
* html .png{
azimuth: expression(
this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none",
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='image')",
this.src = "/images/transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''),
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "', sizingMethod='crop')",
this.runtimeStyle.backgroundImage = "none")),this.pngSet=true
);
}

在head tag之间加上

<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" href="pngfix.css" />
<![endif]-->

早前用javascript来修复的脚本, 这是其中一个script pngfix.js

我现在还用着比较传统的方法因为不想载入更多javascript(其实已载入很多了=.=) 所以我是单一的在css属性加上以下这行

filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='transparent.png', sizingMethod='crop');

Back Top

马来西亚几时才web2.0? 开心车队美吃团

Responses to “针对IE6不支持png”

  1. 没有任何评论。
  1. 没有任何引用。

发表回复

Back Top