9 11月 2007

针对IE6不支持png

分类标签: 网事点滴 , , , , 1,773 次查看 - 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');

还没有评论.

写下评论

(必填)

(必填)

简介

更多关于我
  • Nick:ufo
  • Locate:Malaysia

关注 web标准、CSS、用户体验、IT、设计、品牌、摄影、手绘、漫画、XCM等

最近记录