x
1
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<title>蜜蜂教程(mifengjc.com)</title>
6
<style>
7
#myDIV {
8
margin: auto;
9
border: 1px solid black;
10
width: 200px;
11
height: 100px;
12
background-color: coral;
13
color: white;
14
}
15
</style>
16
</head>
17
<body>
18
19
<p>点击“尝试一下”按钮,旋转 DIV 元素:</p>
20
<button onclick="myFunction()">尝试一下</button>
21
<div id="myDIV">
22
<h1>myDIV</h1>
23
</div>
24
<script>
25
function myFunction() {
26
document.getElementById("myDIV").style.transform = "rotate(20deg)";
27
/* Opera、Chrome 和 Safari */
28
document.getElementById("myDIV").style.WebkitTransform = "rotate(20deg)";
29
/* IE 9 */
30
document.getElementById("myDIV").style.msTransform = "rotate(20deg)";
31
}
32
</script>
33
34
</body>
35
</html>