网页中图片大小自动调整三种方法

1.鼠标滚动图片大小调整



function bbimg(o){
   var zoom=parseInt(o.style.zoom, 10)||100;

zoom+=event.wheelDelta/12;

if (zoom>0)

 o.style.zoom=zoom+'%';


   return false;
}
 
screen.width-screen.width/2) this.style.width=screen.width-screen.width/2" onmousewheel="return bbimg(this)" > 


2.图片自动缩小到固定大小






 


3.滚轮图片缩放的代码


var count = 10;
function resizeimg(oImage)

count = Counting(count);
Resize(oImage,count);
return false;
}
function Counting(newzoom){ 
if (event.wheelDelta >= 120)
newzoom++;
else if (event.wheelDelta <= -120)
newzoom--;
if (newzoom<2) newzoom=2; 只允许缩小到20%
if (newzoom>50) newzoom=50; 只允许放大到500%
return newzoom; 
}
function Resize(oImage,newzoom){ 
oImage.style.zoom = newzoom + '0%'; 
count=newzoom;
}


然后在中加入
onDblClick="return Resize(this,10);return false;" 
onmousewheel="return resizeimg(this)"
 

你可能感兴趣的:(网页中图片大小自动调整三种方法)