<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>飞鱼 ^_^ 浆抱罗斯‘s blog &#187; png</title>
	<atom:link href="http://qilei.org/tag/png/feed/" rel="self" type="application/rss+xml" />
	<link>http://qilei.org</link>
	<description>这里是一个非专业交互设计师 - 飞鱼 的blog。飞鱼的生活就像吃一盘螺丝, 你得努力吸才能品尝到快乐^_^</description>
	<lastBuildDate>Thu, 02 Feb 2012 03:07:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>IE6下PNG图片背景不透明的问题</title>
		<link>http://qilei.org/200808/css-for-png-in-ie6/</link>
		<comments>http://qilei.org/200808/css-for-png-in-ie6/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 12:00:14 +0000</pubDate>
		<dc:creator>飞鱼</dc:creator>
				<category><![CDATA[代码浅谈]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[ie6]]></category>
		<category><![CDATA[png]]></category>

		<guid isPermaLink="false">http://www.qilei.org/word/?p=31</guid>
		<description><![CDATA[周末调试的时候，发现之前的ie6下显示png代码不够完善，于是上网转了篇详细的，一起学习。 CSS解决IE6下PNG图片背景不透明的问题 使用IE6的滤镜来解决 background: url(你的图.png) no-repeat; _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=’你的图.png’); /* IE6 注意这里的png路径最好是绝对路径，因为它是相对于调用的html页面的路径，而不是css目录的相对路径 */ _background-image: none; JS解决IE6下PNG图片不透明的问题 背景png图片可以使用css来解决，如果是img 标签的图片，我则是用js来实现，也比较简单。 以下是网上流行的pngfix.js的代码。下载地址 function correctPNG() // correctly handle PNG transparency in Win IE 5.5 &#38; 6. { var arVersion = navigator.appVersion.split("MSIE") var version = parseFloat(arVersion[1]); if ((version &#62;= 5.5) &#38;&#38; (document.body.filters)) { for(var j=0; j&#60;document.images.length; j++) { var img = [...]]]></description>
			<content:encoded><![CDATA[<p>周末调试的时候，发现之前的ie6下显示png代码不够完善，于是上网转了篇详细的，一起学习。</p>
<h3>CSS解决IE6下PNG图片背景不透明的问题</h3>
<p><em>使用IE6的滤镜来解决</em></p>
<pre><code>background: url(你的图.png)  no-repeat;
_filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=’你的图.png’); /* IE6  注意这里的png路径最好是绝对路径，因为它是相对于调用的html页面的路径，而不是css目录的相对路径 */
_background-image: none;
</code></pre>
<h3>JS解决IE6下PNG图片不透明的问题</h3>
<p>背景png图片可以使用css来解决，如果是img 标签的图片，我则是用js来实现，也比较简单。<br />
以下是网上流行的pngfix.js的代码。<a rel="nofollow" href="http://bbs.redhome.cc/include/javascript/pngfix.js" target="_blank">下载地址</a></p>
<pre><code>
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 &amp; 6.
{
  var arVersion = navigator.appVersion.split("MSIE")
  var version = parseFloat(arVersion[1]);
  if ((version &gt;= 5.5) &amp;&amp; (document.body.filters)) {
    for(var j=0; j&lt;document.images.length; j++) {
     var img = document.images[j];
     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 = "&lt;span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"&gt;&lt;/span&gt;" ;
         img.outerHTML = strNewHTML
       j = j-1 ;
     }
   }
 }
}
window.attachEvent &amp;&amp; window.attachEvent("onload", correctPNG);
</code></pre>
<p><em>===========补充==========</em></p>
<h3>jQuery插件解决IE6下PNG图片不透明的问题</h3>
<p>1.插件下载地址<br />
<a title="http://jquery.com/    (external link)" rel="external" href="http://jquery.com/">Download jQuery<span> </span></a><br />
<a title="http://jquery.andreaseberhard.de/download/pngFix.zip    (external link)" rel="external" href="http://jquery.andreaseberhard.de/download/pngFix.zip">Download pngFix.zip<span> </span></a> <a href="http://jquery.andreaseberhard.de/pngFix/jquery.pngFix.js">jquery.pngFix.js</a><br />
2.使用方法</p>
<pre><code>&lt;script type="text/javascript" src="jquery-latest.pack.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="jquery.pngFix.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
  $(document).ready(function(){
  $(document).pngFix();
});
&lt;/script&gt;
</code></pre>
<h2  class="related_post_title">您可能还对这些日志感兴趣</h2><ul class="related_post"><li><a href="http://qilei.org/201008/addon-class-do-not-run-on-ie-6/" title="又见IE6吐槽~ 并行结构式class引起的bug">又见IE6吐槽~ 并行结构式class引起的bug</a></li><li><a href="http://qilei.org/201202/how-to-make-well-when-position-absolute/" title="position:absolute 的一些兼容心得。">position:absolute 的一些兼容心得。</a></li><li><a href="http://qilei.org/201111/ie6-reflow-bug/" title="IE6 reflow bug 经验因素收集">IE6 reflow bug 经验因素收集</a></li><li><a href="http://qilei.org/201110/zoom1-cause-a-bug/" title="zoom:1 引起的bug 一则 ">zoom:1 引起的bug 一则 </a></li><li><a href="http://qilei.org/201109/vertical-align-in-different-browser/" title="vertical-align 图片文字水平对齐分析">vertical-align 图片文字水平对齐分析</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://qilei.org/200808/css-for-png-in-ie6/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

