首页 > 代码库 > 鼠标滚轮改变图片大小

鼠标滚轮改变图片大小

<!DOCTYPE html">
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>通过鼠标滚动-放大缩小图片</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href=http://www.mamicode.com/"" rel="stylesheet">
<style>
    img{
        zoom: 100%;
    }
</style>
</head>
<script language="javascript">
    function bigimg(i)
    {
        var e=e || window.event;//window.event代表着事件对象的状态.只有在事件发生时生效

        var zoom = parseInt(i.style.zoom,10)||100;

        zoom += e.wheelDelta / 12;
        if(zoom > 0 )
        i.style.zoom=zoom+%;
        return false;
    }
</script>
<body>
<h3>请滚动鼠标滚轮-火狐浏览器不兼容</h3>
<center>
    <a target="_blank">
        <img src=http://www.mamicode.com/"img/wall7.jpg" width="461" height="277" border="1" onm ousewheel="return bigimg(this)">
    </a>
</center>


</body>
</html>

 

鼠标滚轮改变图片大小