现在在很多论坛上见过一个图片功能,当发的帖子当中有图片的时候,点击图片就会出现一个放大图片的功能,随着鼠标滚轮的转动,图片出现放大和缩小,我搜索了百度,没有找到这个代码,请提供一下,谢谢!

解决方案 »

  1.   

    sample:
    <img id=img1></img>
    <script>
    var obj=document.getElementById("img1");
    obj.style.width="20px";
    obj.style.height="20px";
    obj.onclick=function(){
        this.style.width="100px";
        this.style.height="100px";
    };
    document.onmousewheel =function(){
        if(event.wheelDelta>0){
           if(parseInt(obj.style.width)>1024)return;
           obj.style.width=parseInt(obj.style.width)*1.5+"px";
           obj.style.height=parseInt(obj.style.height)*1.5+"px";
        }else{
           if(parseInt(obj.style.width)<10)return;
         obj.style.width=parseInt(obj.style.width)/1.5+"px";
         obj.style.height=parseInt(obj.style.height)/1.5+"px";
        }
        
    };
    </script>
      

  2.   

    半透明:filter:alpha(style=0,opacity=30)