<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>css画一个正方体</title>
  <style>
    @keyframes flash {
      0%{ transform: rotateY(0) rotateX(0); }
      100%{ transform: rotateY(360deg) rotateX(360deg); }
    }
    .box {
      width: 100px;
      height: 100px;
      position: relative;
      margin: 100px auto 0;
      transform-style: preserve-3d;
      animation: flash 3s linear infinite;
    }
    .box > div {
      position: absolute;
      width: 100px;
      height: 100px;
      transition: all 1s;
    }
    .box>div:nth-of-type(1){ background: lightblue; }
    .box>div:nth-of-type(2){ background: lime; }
    .box>div:nth-of-type(3){ background: lightseagreen; }
    .box>div:nth-of-type(4){ background: orange; }
    .box>div:nth-of-type(5){ background: darkorchid; }
    .box>div:nth-of-type(6){ background: pink; }

    .box>div:nth-of-type(1){ transform: translateZ(-50px); }
    .box>div:nth-of-type(2){ transform: rotateX(90deg) translateZ(50px); }
    .box>div:nth-of-type(3){ transform: rotateX(90deg) translateZ(-50px); }
    .box>div:nth-of-type(4){ transform: rotateY(90deg) translateZ(50px);}
    .box>div:nth-of-type(5){ transform: rotateY(90deg) translateZ(-50px);}
    .box>div:nth-of-type(6){ transform: translateZ(50px); }
  </style>
</head>
<body>
  <div class="box">
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
    <div>5</div>
    <div>6</div>
  </div>
</body>
</html>

效果
正方体.gif


记得要微笑
1.9k 声望4.5k 粉丝

知不足而奋进,望远山而前行,卯足劲,不减热爱。


引用和评论

0 条评论