跳至主要內容

立体呈现

HeChuangJun约 153 字小于 1 分钟

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>立体呈现</title>
    <style>
      .cube {
        position: relative;
        width: 200px;
        height: 200px;
        margin: 100px auto;
        transition: all 2s;
        transform-style: preserve-3d;
        /* 旋转与案例效果无关,用来看前后移动的效果 */
        /* transform: rotateY(89deg); */
      }
      .cube div {
        position: absolute;
        left: 0;
        top: 0;
        width: 200px;
        height: 200px;
      }
      .front {
        background-color: orange;
        transform: translateZ(100px);
      }
      .back {
        background-color: green;
        transform: translateZ(-100px);
      }
      .cube:hover {
        transform: rotateY(90deg);
      }
    </style>
  </head>
  <body>
    <div class="cube">
      <div class="front">前面</div>
      <div class="back">后面</div>
    </div>
  </body>
</html>