通过onmousewheel实现图片的放大与缩小问题,继续滚动滚轮继续放大

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>无标题文档</title>

<style>

#pic{ width:135px; height:240px; margin:0 auto;}

#pic img{width:135px; height:240px;}

</style>

</head>


<body>

<div id="pic">

<img src="123.JPG">

<script>

var pic=document.getElementById("pic")

pic.onmousewheel=function(event){

//alert(event.wheelDelta)

if(event.wheelDelta>0){

pic.style.transform="scale(2,2)";

}

else if(event.wheelDelta<0){

pic.style.transform="scale(1,1)"

}

}

</script>

</div>

</body>

</html>


Echo_Chien
浏览 1778回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript