美文网首页H5
正方体旋转css简单实现

正方体旋转css简单实现

作者: 狗蛋的春天 | 来源:发表于2021-09-18 17:26 被阅读0次

    正方体旋转 简单css实现

    IMG_2503.GIF
        <!DOCTYPE html>
        <html lang="en">
        <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>正方形</title>
        <style>
            * {
                margin: 0px;
                padding: 0px;
             }
          .bbbb {
              width: 200px;
              height: 200px;
              margin: 250px auto;
           }
          .box {
              position: relative;
              width: 200px;
              height: 200px;
              /* border: 1px solid gray; */
               perspective: 8000px;
              transition: all 5s ease;
              transform-style: preserve-3d;
            }
          .box p{
              position: absolute;
              left: 0px;
              top: 0px;
              width: 200px;
              height: 200px;
              text-align: center;
              font: bold 30px/200px "微软雅黑";
          }
          .box p:nth-child(1){
              background-color: rgba(123, 111, 1, 0.2);
              transform: rotateX(180deg) translateZ(100px);
          }
          .box p:nth-child(2){
              background-color: rgba(255, 255, 1, 0.2);
              transform-origin: left center;
              transform:rotateY(270deg) translateX(-100px);
          }
          .box p:nth-child(3){
              background-color: rgba(224, 13, 6, 0.2);
              transform-origin: top center;
              transform:rotateX(90deg) translateY(-100px);
          }
          .box p:nth-child(4){
              background-color: rgba(1, 203, 24, 0.2);
              transform-origin: bottom center;
              transform:rotateX(-90deg) translateY(100px);
          }
          .box p:nth-child(5){
              background-color: rgba(12, 15, 177, 0.2);
              transform-origin: right center;
              transform:rotateY(-90deg) translateX(100px);
          }
          .box p:nth-child(6){
              background-color: rgba(228, 21, 38, 0.2);
              transform: translateZ(100px);
          }
          .box:hover{
              transform: rotateX(360deg) rotateY(360deg);
    
          }
        </style>
    </head>
    <body>
      <div class="bbbb">
          <div class="box">
              <p>1</p>
              <p>2</p>
              <p>3</p>
              <p>4</p>
              <p>5</p>
              <p>6</p>
          </div>
      </div>
    
    
    </body>
    

    </html>

    相关文章

      网友评论

        本文标题:正方体旋转css简单实现

        本文链接:https://www.haomeiwen.com/subject/ykrygltx.html