有两张图片,一张为背景图片 要用javascript控制背景图片的大小。用鼠标滚轮控制。 另外一张要放在背景图片上面。 就像是百度地图似的。 不管背景图片如何放大 另外一张图片一直定点在某个位置。随之背景图片的大小而移动。

解决方案 »

  1.   


    <SCRIPT language=JavaScript type=text/JavaScript>    
    //改变图片大小    
    function resizepic(o)    
    {     
    var maxwidth=550;   //定义最大宽度    
    var maxheight=800;  //定义最大高度    
    var a=new Image();    
    a.src=o.src    
    if(a.width > maxwidth)    
    {    
      o.style.width=maxwidth;    
    }    
    if (a.height> maxheight)    
    {    
      o.style.height=maxheight;    
     }    
    }    
    //无级缩放图片大小    
    function bbimg(o)    
    {    
      var zoom=parseInt(o.style.zoom, 10)||100;    
      zoom+=event.wheelDelta/12;    
      if (zoom>0) o.style.zoom=zoom+'%';    
      return false;    
    }    
    </SCRIPT>   
    对于那个固定不动的,设置css属性,position;fixed就可以了
      

  2.   

    楼上的大哥,  不是要固定不动,  而是要根据背景图片的大小 来移动位置。 
    就好比是拿javascript做出百度地图那种效果。
      

  3.   

    鼠标滚轮的事件只有IE支持
    onmousewheel
      

  4.   


    <IMG id='img1' src='356173.gif' onmousewheel = 'wheel(this)' style='width:10px' />
    <SCRIPT>
    function wheel(obj)
    {    
        var width = parseInt(obj.style.width);
        if (event.wheelDelta > 0)
        {
            obj.style.width = (width + 10) + 'px';                         
        } 
        else
        {
            obj.style.width = (width - 10) + 'px'; 
        }
    }
    </SCRIPT>鼠标滚轮控制图片大小,只有IE能做