天蓬老师2017-04-10 17:43:57
直接上demo好了,代码写的仓促,但是大概流程就是这样
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="author" content="zp" />
<title>图片旋转</title>
<style type="text/css">
#img{
border: 1px solid #000;
display: block;
}
</style>
</head>
<body>
<img src="logo.png" id="img" />
<button id="button">旋转</button>
<script type="text/javascript">
var deg = 0;
document.getElementById("button").onclick = function () {
deg += 90;
document.getElementById("img").style.transform = "rotate(" + deg + "deg)";
}
</script>
</body>
</html>