創意水晶CSS3 - 3D立方體效果

來源:互聯網
上載者:User

標籤:dash   form   ati   init   image   set   before   ash   transform   

<!doctype html>

<html lang="en">

 <head>

  <meta charset="UTF-8">

  <title>3D立方體</title>

  <style>

         .box{

                   width: 249px;

                   height: 249px;

                   border: 1px dashed #000;

                   margin: 120px auto;

                   border-radius: 250px;

                   position: relative;

 

                   /* 讓子盒子保持3D效果 */

                   transform-style: preserve-3d;

                  

                   /* 父盒子變換 */

                   /* transform:rotateX(30deg) rotateY(-30deg); */

                  

                   /* 動畫*/

                   animation: gun 8s linear infinite;

         }

         /* 愛心 */

         .box::before,.box::after{

                   content: "";

                   width: 50px;

                   height: 80px;

                   background: pink;

                  position: absolute;

                   border-radius: 50px 50px 0 0;

                   top: 50%;

                   left: 50%;

         }

         .box::before{

                   transform: rotate(-45deg);

                   margin-left: -36px;

                   margin-top: -40px;

         }

         .box::after{

                   transform: rotate(45deg);               

                   margin-left: -16px;

                   margin-top: -40px;

         }

        

         @keyframes gun{

                   0%{

                            transform:rotateX(0deg) rotateY(0deg)

                   }

                   100%{

                            transform:rotateX(360deg) rotateY(360deg)

                   }

         }

         /* 選中box下面的所有div */

         .box > div{

                   width: 100%;

                   height: 100%;          

                   text-align: center;            

                   line-height: 250px;

                   font-size: 60px;

                   position: absolute;

                   color: #fff;

         }

         /* 左盒子 */

         .left{

                   background-color: rgba(255,0,0,0.3);

                   transform-origin: left;

                   transform: rotateY(-90deg) translateX(-125px);

         }

         /* 右盒子 */

         .right{

                   background-color:rgba(0,255,0,0.3);

                   transform-origin: right;

                   transform: rotateY(90deg)translateX(125px);

         }

         /* 前盒子 */

         .forward{

                   background-color: rgba(0,0,255,0.3);

                   transform: translateZ(125px);

         }

         /* 後盒子 */

         .back{

                   background-color: rgba(0,125,125,0.3);

                   transform: rotateY(-180deg) translateZ(125px);

         }

         /* 上盒子 */

         .up{

                   background-color: rgba(125,125,0,0.3);

                   transform: rotateX(90deg) translateZ(125px);

         }

         /* 下盒子 */

         .down{

                   background-color: rgba(125,125,225,0.3);

                   transform: rotateX(-90deg) translateZ(125px);

         }

  </style>

 </head>

 <body>

  <div class = "box">

         <div class = "up">上</div>

         <div class = "down">下</div>

         <div class = "left">左</div>

         <div class = "right">右</div>

         <div class = "forward">前</div>

         <div class = "back">後</div>

  </div>

 </body>

</html>

【web前端交流學習群018】群號498854752

創意水晶CSS3 - 3D立方體效果

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.