无为清净楼资源网 Design By www.qnjia.com

  png图片有很好的品质。阴影效果也不会有杂边,很流畅。如果插入网页的话可以给网站内容增色不少!更重要的是在不增加图片容量大小的情况下提高了页面的图片的质量。对于有复杂背景,如:在有颜色过度背景上插入不规则边框的图片带来极大很便利!
  但目前IE中对于插入的透明背景的.png的图片是不能正常显示的。IE会自动给".png"格式的图片加个灰色背景。
  解决这个的方法是增加javascript。具体方法如下:
  把下面的代码放在head区就可以解决问题了。
<scriptlanguage="javascript">
functioncorrectPNG()
{
for(vari=0;i<document.images.length;i )
{
varimg=document.images[i]
varimgName=img.src.toUpperCase()
if(imgName.substring(imgName.length-3,imgName.length)=="PNG")
{
varimgID=(img.id)?"id='" img.id "'":""
varimgClass=(img.className)?"class='" img.className "'":""
varimgTitle=(img.title)?"title='" img.title "'":"title='" img.alt "'"
varimgStyle="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
varstrNewHTML="<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>
标签:
教程,网页制作,网页,图片,正确,显示,透明,",imgStyle

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com