if(id2==0){ var r=sc.getDat({ Fields:'top 1 id', Filter:'isc=1 and tid='+id1 +' order by sort, id desc', Table :'SC_Def' }); if(r.length){ id2=r[0].id; }else{ id2=id1; } } %>
 
 
 

您的当前位置:首页 > 学堂首页学习教程网站排版

分享到:
0

网站排版

在IE浏览器中正确显示PNG透明图片

添加时间:2011-09-09  点击次数:1202  【返回】
PNG图片有很好的品质。阴影效果也不会有杂边,很流畅。如果插入网页的话可以给网站内容增色不少!更重要的是在不增加图片容量大小的情况下提高了页面的图片的质量。对于有复杂背景,如:在有颜色过度背景上插入不规则边框的图片带来极大很便利! 

但目前IE中对于插入的透明背景的.png的图片是不能正常显示的。IE会自动给".png"格式的图片加个灰色背景。 

解决这个的方法是增加javascript。具体方法如下: 

把下面的代码放在head区就可以解决问题了。 

以下是引用片段: 

<script language="javascript"> 
function correctPNG()  

for(var i=0; i<document.images.length; i++) 

  var img = document.images[i] 
  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 = "<span " + imgID + imgClass + imgTitle 
   + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" 
  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" 
   + "(src=\’" + img.src + "\’, sizingMethod=’scale’);\"></span>"  
   img.outerHTML = strNewHTML 
   i = i-1 
  } 


window.attachEvent("onload", correctPNG); 
 </script> 

也可以把这段代码单独加在一张图片上: 

以下是引用片段: 

<span 
style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=’male.png’,sizingMethod=’scale’);"></span >

销售热线:0755-26430418,26435736, 售后服务:0755-26435726,86063568,  续费专线:0755-26435736,  E-mail:kf@510888.cn
Copyright © 2003-2021 深圳市赛奥特网络有限公司 All Rights Reserved. 备案序号:粤ICP备06028019号
网站建设网站运营网站推广,专业团队尽心尽力为客户做好每一个细节!  
深圳网站建设深圳网页设计深圳网站制作深圳建网站赛奥特网络网站建设网站推广域名注册虚拟主机企业邮箱网络营销电子商务网站制作网站设计网站服务企业网站企业信息化