<?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>前端思考：专注前端开发，关注用户体验 &#187; png透明</title>
	<atom:link href="http://www.artcss.com/archives/tag/png%e9%80%8f%e6%98%8e/feed" rel="self" type="application/rss+xml" />
	<link>http://www.artcss.com</link>
	<description>一个像素的距离...</description>
	<lastBuildDate>Sat, 12 Feb 2011 03:34:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>IE6下，png透明最好的解决方案</title>
		<link>http://www.artcss.com/archives/294.html</link>
		<comments>http://www.artcss.com/archives/294.html#comments</comments>
		<pubDate>Tue, 29 Sep 2009 16:33:00 +0000</pubDate>
		<dc:creator>Artcss</dc:creator>
				<category><![CDATA[个人随笔]]></category>
		<category><![CDATA[DD_belatedPNG]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[png透明]]></category>

		<guid isPermaLink="false">http://www.artskin.cn/blog/?p=294</guid>
		<description><![CDATA[透明png（准确的说是png-24）图片在网页上的应用，可以做出各种特效，使网页变得更加漂亮! 现在大部分浏览器都支持png透明，要命的IE6，却不支持！怎么办呢？从网上一搜，IE6下的png透明的解决方法有好多，自己以前也试过好多方法，有的只能背景透明，有的只能图片透明，而且背景透明的必须要给需要透明的图片指定宽和高，不能背景平铺，也就不能使用background-position属性，这使用起来就很不方便。 最后，我找到了一种方法，上边的那些问题都能解决，而且使用起来也非常方便，所以极力推进给大家。 这个js插件使用了微软的VML语言进行绘制,而其他多数解决PNG问题的js插件用的是AlphaImageLoader滤镜. 这种方法就是借助DD_belatedPNG，它不仅支持backgrond-position与background-repeat.同时还支持focus和a:hover属性,以及img的透明 使用方法 1.在这里下载DD_belatedPNG.js文件. 2.在网页中引用,如下: Download script.js1 2 3 4 5 6 7 8 9 10 &#60;!--&#91;if lte IE 6&#93;&#62; &#60;script type=&#34;text/javascript&#34; src=&#34;http://www.artcss.com/js/dd_belatedpng.js&#34;&#62;&#60;/script&#62; &#60;script type=&#34;text/javascript&#34;&#62; DD_belatedPNG.fix&#40;'.png_bg,img'&#41;; /* 将 .png_bg 改成你应用了透明PNG的CSS选择器*/ &#60;/script&#62; &#60;!&#91;endif&#93;--&#62; /*页面中这样写：*/ &#60;img src=&#34;xxx.png&#34; /&#62; &#60;div class=&#34;png_bg&#34;&#62;&#60;/div&#62; 3.有2种调用函数,一种是DD_belatedPNG.fix(),如上代码.另一种是fix(),这中方法需要在函数内指出css选择器名. 官方地址: http://www.dillerdesign.com/experiment/DD_belatedPNG/ 请看下边实例 &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62; &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>透明png（准确的说是png-24）图片在网页上的应用，可以做出各种特效，使网页变得更加漂亮!</p>
<p>现在大部分浏览器都支持png透明，要命的IE6，却不支持！怎么办呢？从网上一搜，IE6下的png透明的解决方法有好多，自己以前也试过好多方法，有的只能背景透明，有的只能图片透<span id="more-294"></span>明，而且背景透明的必须要给需要透明的图片指定宽和高，不能背景平铺，也就不能使用background-position属性，这使用起来就很不方便。</p>
<p>最后，我找到了一种方法，上边的那些问题都能解决，而且使用起来也非常方便，所以极力推进给大家。</p>
<p>这个js插件使用了微软的VML语言进行绘制,而其他多数解决PNG问题的js插件用的是AlphaImageLoader滤镜.</p>
<p>这种方法就是借助DD_belatedPNG，它不仅支持backgrond-position与background-repeat.同时还支持focus和a:hover属性,以及img的透明</p>
<p>使用方法</p>
<p>1.在这里下载<a href="http://www.artcss.com/js/dd_belatedpng.js">DD_belatedPNG.js</a>文件.</p>
<p>2.在网页中引用,如下:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left2">Download <a href="http://www.artcss.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=294&amp;download=script.js">script.js</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2942"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p294code2"><pre class="javascript" style="font-family:Verdana;"><span style="color: #339933;">&lt;!--</span><span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">if</span> lte IE <span style="color: #ff0000;">6</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://www.artcss.com/js/dd_belatedpng.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
  DD_belatedPNG.<span style="color: #990000;">fix</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.png_bg,img'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009966; ">/* 将 .png_bg 改成你应用了透明PNG的CSS选择器*/</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;!</span><span style="color: #009900;">&#91;</span>endif<span style="color: #009900;">&#93;</span><span style="color: #339933;">--&gt;</span>
<span style="color: #009966; ">/*页面中这样写：*/</span>
<span style="color: #339933;">&lt;</span>img src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;xxx.png&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>div <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;png_bg&quot;</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>3.有2种调用函数,一种是DD_belatedPNG.fix(),如上代码.另一种是fix(),这中方法需要在函数内指出css选择器名.</p>
<h4>官方地址:</h4>
<p><a href="http://www.dillerdesign.com/experiment/DD_belatedPNG/">http://www.dillerdesign.com/experiment/DD_belatedPNG/</a></p>
<h4>请看下边实例</h4>
<div class="runcode">
<p><textarea name="runcode" class="runcode_text" id="runcode_PquChz">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;meta name=&quot;author&quot; content=&quot;artskin@163.com,guliqiang&quot; /&gt;
&lt;meta name=&quot;Keywords&quot; content=&quot;前端思考&quot; /&gt;
&lt;meta content=&quot;all&quot; name=&quot;robots&quot; /&gt;
&lt;title&gt;IE6下，png透明最好的解决方案 || 前端思考&lt;/title&gt;
&lt;!--[if lte IE 6]&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.artcss.com/js/dd_belatedpng.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  DD_belatedPNG.fix('img,li,.title,a:hover');
&lt;/script&gt;
&lt;![endif]--&gt;
&lt;style&gt;
&lt;!--
h1{width:730px;text-align:center;font-size:16px}
.main{width:730px;height:500px;border:1px solid #ccc;background:#333 url(/wp-content/uploads/test/img/bg.jpg)}
.title{height:120px;background:url(/wp-content/uploads/test/img/title.png) center center no-repeat;}
ul{width:230px;height:200px;padding-top:50px;float:left}
ul li{list-style:none;padding-left:23px;font-size:14px;color:#898989;line-height:30px;background:url(/wp-content/uploads/test/img/icon.png) left center no-repeat}
.author{float:right;padding-right:20px;}
a{color:#ccc;font-weight:bold;text-decoration:none}
a:hover{background:url(/wp-content/uploads/test/img/txt.png) -2px -2px no-repeat}
p{clear:both;color:#bbb;padding-left:40px;}
--&gt;
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;需要刷新一下才可以！&lt;/h1&gt;
&lt;div class=&quot;main&quot;&gt;
	&lt;div class=&quot;title&quot;&gt;&lt;/div&gt;
	&lt;ul&gt;
		&lt;li&gt;单反相机&lt;/li&gt;
		&lt;li&gt;定焦相机&lt;/li&gt;
		&lt;li&gt;变焦相机&lt;/li&gt;
		&lt;li&gt;普通光学取景&lt;/li&gt;
		&lt;li&gt;多重测光模式&lt;/li&gt;
	&lt;/ul&gt;
	&lt;div class=&quot;author&quot;&gt;&lt;img src=&quot;/wp-content/uploads/test/img/author.png&quot; alt=&quot;摄影师&quot; /&gt;&lt;/div&gt;
	&lt;p&gt;png的a:hover,|&lt;a href=&quot;#&quot;&gt;放上来试试！&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_PquChz');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_PquChz');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<h4>经典应用实例：</h4>
<p><a href="http://www.hxsd.com/news/zhuantipindao/090917sheying/">http://www.hxsd.com/news/zhuantipindao/090917sheying/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.artcss.com/archives/294.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

