扫码关注官方订阅号
js如何实现鼠标拖拽旋转功能,目前我已做成鼠标拖放功能,想加个旋转不知道该怎么做啦,效果类似美图秀秀app上的图片旋转功能
ringa_lee
<!DOCTYPE html> <html> <head> <style> p { width:100px; height:100px; background:red; position:relative; } </style> <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script> <script type="text/javascript"> $(function(){ var oldY= null; var isdown = false; $("#testcss").mousedown(function(e){ isdown = true; oldY = e.clientY; }); $("html").mousemove(function(e){ if(isdown){ $("#testcss").css("transform","rotate("+(e.clientY-oldY)+"deg)"); } }); $("html").mouseup(function(e){ isdown = false; oldY = null; }); }); </script> </head> <body> <p id="testcss"></p> </body> </html>
旋转用css3的属性transform: rotate(90deg);
这种问题问的太多了
传送门
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
旋转用css3的属性
transform: rotate(90deg);
这种问题问的太多了
传送门