前端页面,90°翻转图片、滚动鼠标滑轮放大缩小图片

话不多说,直接上代码:

 
 
#set($_title = "查看司机照片")
#parse("common/_header.vm")
<style>
.img{
overflow-y: auto;
overflow-x: auto;
}
</style>
</head>
<body class="img">
<img id="target" src="$!{url}" onmousewheel="return bigimg(this)" style="cursor:pointer">
<script>
window.onload = function(){
var current = 0;
document.getElementById('target').onclick = function(){
current = (current+90)%360;
this.style.transform = 'rotate('+current+'deg)';
}
};
function bigimg(obj){
var zoom = parseInt(obj.style.zoom,10)||100;
zoom += event.wheelDelta / 20;
if(zoom > 0 )
obj.style.zoom=zoom+'%';
return false;
}
</script>
</body>
</html>


代码解析:

 

 
其中 onmousewheel="return bigimg(this)"  控制鼠标滑轮的滚动事件。(其中放大缩小比例可以通过修改  zoom += event.wheelDelta / 20;  后面的分母,分母越小,滚动一次缩放比例越大)
下面这段代码控制点击翻转图片90°。
window.onload = function(){
var current = 0;
document.getElementById('target').onclick = function(){
current = (current+90)%360;
this.style.transform = 'rotate('+current+'deg)';
}
};


 
 

转载于:https://www.cnblogs.com/dk1024/p/10278166.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值