x
 
<!DOCTYPE html>
<html>
<head>
<style>
#div1 {
  position: relative;
  margin: auto;
  height: 150px;
  width: 250px;
  padding: 10px;
  border: 1px solid black;
  perspective: 200px;
}
#div2 {
  padding: 50px;
  position: absolute;
  border: 1px solid black;
  background-color: red;
  transform: rotateX(45deg);
}
</style>
</head>
<body>
<p>点击“试一试”按钮可更改 DIV1 元素的 perspecive 属性:</p>
<button onclick="myFunction()">试一试</button>
<div id="div1">DIV1
  <div id="div2">把自己想象成一只鸟,俯视着一堵墙。然后点击按钮,看看当您改变视角时会发生什么!</div>
</div>
<script>
function myFunction() {
  document.getElementById("div1").style.perspective = "100px";
}
</script>
</body>
</html>