<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>每点击一下,旋转90°</title>
<style>
#box{
width: 150px;
height: 120px;
background: red;
transition: all 3s ease;
}
</style>
</head>
<body>
<div id = "box"></div>
<button onclick="func();">开始</button>
<script>
var box1 = document.getElementById("box");
var rotateTimes = 1;
function func(){
box.style.transform = 'rotateY('+180*rotateTimes+'deg)';
rotateTimes++;
}
</script>
</body>
</html>
js通过按钮控制图片旋转
最新推荐文章于 2024-08-09 14:33:13 发布