HTML部分代码
<img class="alert_img" onmousewheel="return suofang(this)" style="max-width: 150%; max-height: 150%;zoom:70%;" src="https://www.baidu.com/img/flexible/logo/pc/result.png" alt="缩放图片">
//样式:"max-width: 150%; max-height: 150%;zoom:70%;" 可以不用填写
JS部分代码
<script>
function suofang(that){
var zoom=parseInt(that.style.zoom, 10)||100;
console.log("zoom:",zoom);
zoom+=event.wheelDelta/12;
if (zoom>0) that.style.zoom=zoom+'%';
return false;
}
</script>