我看了网上的一些实例用CSS的,确实有用。
不过遇到一个问题,我用js控制图片切换,网页刚刷新的时候是正常的,切换后就不透明了,了解的帮帮忙啦!

解决方案 »

  1.   

    我用的是CSS做的,js里使用className设置,可是不起作用
      

  2.   


    .pngfix 
    {
    azimuth: expression(
    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 = "images/blank.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);
    }[code=JScript]
    // 切换头像
    var iconid = 1; // 图片名起始数 1.gif
    var iconmax = 8; // 图片名最大值 8.giffunction prev()
    {
        iconid -= 1;
        
        if(iconid < 1) { iconid = iconmax; }
        
        var imgIcon = document.getElementById("imgIcon");
        imgIcon.src = "icons/" + iconid + ".png";
        imgIcon.className = "pngfix";
        document.getElementById("hdnIcon").value = iconid + ".png";
    }function next()
    {
        iconid += 1;
        
        if(iconid > 8 ) { iconid = 1; }
        
        var imgIcon = document.getElementById("imgIcon");
        imgIcon.src = "icons/" + iconid + ".png";
        imgIcon.className = "pngfix";
        document.getElementById("hdnIcon").value = iconid + ".png";
    }[/code]