<html>
<head>
<style>
#myDIV
{
margin:auto;
border:1px solid black;
width:200px;
height:100px;
background-color:coral;
color:white;
}
</style>
</head>
<body>
<p>点击“尝试一下”按钮,旋转 DIV 元素:</p>
<button onclick="myFunction()">尝试一下</button>
<div id="myDIV">
<h1>myDIV</h1>
</div>
<script>
function myFunction()
{
document.getElementById("myDIV").style.transform = "rotate(20deg)";
/* Opera、Chrome 和 Safari */
document.getElementById("myDIV").style.WebkitTransform = "rotate(20deg)";
/* IE 9 */
document.getElementById("myDIV").style.msTransform = "rotate(20deg)";
}
</script>
</body>
</html>