运行结果尺寸: 300 x 150
x
 
<!DOCTYPE html>
<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() {
  // Code for IE9
  document.getElementById("myDIV").style.msTransform = "rotate(20deg)"; 
  // 标准语法
  document.getElementById("myDIV").style.transform = "rotate(20deg)"; 
}
</script>
<p><b>注意:</b> Internet Explorer 9 支持替代方法,即 msTransform 属性。 较新版本的 IE 和 Edge 支持 transform 属性(不需要 ms 前缀)。</p>
</body>
</html>
×

报个问题: