自学 Flask 系列(四)多种方式,实现点击按钮图片旋转

it2023-07-02  67

多种方式,实现点击按钮图片旋转

点击按钮实现向左或者向右旋转90度,点击四次也就是直至旋转到360度,恢复原状,

方法一、js实现

<!DOCTYPE html> <html> <head> <title>图片旋转</title> <script> window.onload = function(){ var current = 0; document.getElementById('rotate').onclick = function(){ current = (current+90)%360; this.style.transform = 'rotate('+current+'deg)'; } }; </script> </head> <body> <img id ="rotate" src=""> </body> </html>

方法二、jQuery实现

<button class="btn btn-default" style="float: right;" type="button" id="rotate_image">旋转图片</button> <img sr
最新回复(0)