Discuz!官方免费开源建站系统

 找回密码
 立即注册
搜索

[已解决] DZX1 png logo不透明!

[复制链接]
592xc.net 发表于 2010-6-27 21:24:23 | 显示全部楼层 |阅读模式
本帖最后由 592xc.net 于 2010-6-27 21:42 编辑

logo 是png的格式在 IE6下不为透明的 在网上找了好久都解决不了 谁能解决一下  网站地址:
  1. http://592xc.net
复制代码
注明:IE7以上版本是可以正常的 就是IE6不行  希望 谁能帮忙解决一下!


回复

使用道具 举报

ppll0001 发表于 2010-6-28 03:37:25 | 显示全部楼层
本帖最后由 ppll0001 于 2010-6-28 16:15 编辑
回复


    你要是做网站的LOGO  做成 PNG的试试就知道了 记得要在IE6看哦  我们不能总想着自己用IE8   ...
592xc.net 发表于 2010-6-28 02:51



IE6对24位PNG的透明位置显示不出来,确实支持不好,我给你点解决办法。

第一种,只是背景,那么加上滤镜。。。

CSS中这样写:
  1. .pic { background:url(123.png) no-repeat; _background:none; _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='123.png');}
复制代码
然后把这个样式指定到需要的DIV
  1. <div class="pic"></div>
复制代码
这种写法可以让背景 PNG 透明掉,但是有缺陷,背景图不可以平铺,还有如果在这个 pic 容器里有按钮等比如类似DZX的搜索在IE6下会失效,那么就在容器里给个 position:relative 属性。。

第二种,插入的图像是 PNG 而不是背景,这个不能多用,如果用多了,网页载入会很慢的。。。

css中这样写:
  1. * html .pic img{ azimuth: expression_r(
  2. 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 = "abc.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); }
复制代码
abc.gif 自己弄张透明的图,大小不限制。。

然后
  1. <div class="pic"><img src="123.png"  /></div>
复制代码
这样,这个PNG就可以透明了。。。。 注意,只有在 DIV 的 class 为 pic 的时候插入才透明,如果你想全站 PNG 图片插入都透明,那就
  1. * html .pic img
复制代码
改成
  1. * html  img  
复制代码
但是绝对不建议这样使用。。。

上面就可以解决PNG在IE6的透明问题。。。。

还有种方法,以 JS 来实现,使用后全站的 PNG 图片也透明,但是不能用在背景上,我也给你写上:
  1. <script language="JavaScript">
  2. function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
  3. {
  4.     var arVersion = navigator.appVersion.split("MSIE")
  5.     var version = parseFloat(arVersion[1])
  6.     if ((version >= 5.5) && (document.body.filters))
  7.     {
  8.        for(var j=0; j<document.images.length; j++)
  9.        {
  10.           var img = document.images[j]
  11.           var imgName = img.src.toUpperCase()
  12.           if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
  13.           {
  14.              var imgID = (img.id) ? "id='" + img.id + "' " : ""
  15.              var imgClass = (img.className) ? "class='" + img.className + "' " : ""
  16.              var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
  17.              var imgStyle = "display:inline-block;" + img.style.cssText
  18.              if (img.align == "left") imgStyle = "float:left;" + imgStyle
  19.              if (img.align == "right") imgStyle = "float:right;" + imgStyle
  20.              if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
  21.              var strNewHTML = "<span " + imgID + imgClass + imgTitle
  22.              + " style="" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
  23.              + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
  24.              + "(src=\'" + img.src + "\', sizingMethod='scale');"></span>"
  25.              img.outerHTML = strNewHTML
  26.              j = j-1
  27.           }
  28.        }
  29.     }     
  30. }
  31. window.attachEvent("onload", correctPNG);
  32. </script>
复制代码
这段代码,你可以直接放在
  1. <head></head>
复制代码
之间,也可以保存为 .js 文件,比如叫 123.js 然后在  <head></head> 之间插入
  1. <script src="123.js" type="text/javascript"></script>
复制代码
就可以了

之后
  1. <img src="123.png"  />
复制代码
这样的将全部透明。。。。。。。。


评分

2

查看全部评分

回复

使用道具 举报

kingfn 发表于 2010-6-28 08:18:56 | 显示全部楼层
回复 592xc.net 的帖子


    你保存logo 时候 用PNG8格式就行了  IE6不支持怕24位
回复

使用道具 举报

tongshao 发表于 2010-6-28 08:31:52 | 显示全部楼层
呵呵  解决了吗?
回复

使用道具 举报

tongshao 发表于 2010-6-28 08:33:05 | 显示全部楼层
真够麻烦的啊,gif的确不理想,如果可以的话,把背景做出来也是不错的办法....
回复

使用道具 举报

xlxtl 发表于 2010-9-21 06:04:27 | 显示全部楼层
不晓得官方是怎么解决的,哎,也不给个办法
回复

使用道具 举报

zuoguang 发表于 2010-9-30 14:33:49 | 显示全部楼层
收录了
回复

使用道具 举报

创业狼.com 发表于 2010-9-30 15:51:20 | 显示全部楼层
回复

使用道具 举报

anydoo 发表于 2010-10-1 20:15:23 | 显示全部楼层
官方是怎么弄的????????
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-9-6 02:21 , Processed in 0.106807 second(s), 15 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表