码迷,mamicode.com
首页 > Web开发 > 详细

创意水晶CSS3 - 3D立方体效果

时间:2017-03-06 14:01:53      阅读:177      评论:0      收藏:0      [点我收藏+]

标签: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立方体效果

标签:dash   form   ati   init   image   set   before   ash   transform   

原文地址:http://www.cnblogs.com/ZZZAB/p/6508986.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!