ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

两个立方体旋转

2019-05-07 21:56:29  阅读:264  来源: 互联网

标签:两个 translateZ 90deg 100px transform 旋转 rgba 0.4 立方体


<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>3D立方体</title>
    <style>
        .box1{
            width: 200px;
            height: 200px;
            position: absolute;
            /*绝对定位后就不是块元素了,可以模拟*/
            left: 0;
            right: 0;
            bottom: 0;
            top: 0;
            margin: auto;
            animation:aa 4s infinite linear;
            transform:rotate3d(1,1,0,-30deg);
            -webkit-transform-style:preserve-3d;

        }
        @-webkit-keyframes aa{
        	0%{
        		-webkit-transform:rotateY(-600deg) rotateX(300deg);
        		 /*translateX(200px)*/
        	}
        	100%{
        		-webkit-transform:rotateY(200deg) rotateX(-300deg);
        	}
        }
        .box1 .child1{
            width: 200px;
            height: 200px;
            text-align: center;
            line-height:200px;
            font-size: 3em;
            position: absolute;
            transition:all 1s;
        }
        .box1 .child1:nth-child(1){
            background: rgba(45,145,230,0.4);
            /*transform:rotateX(90deg) translateZ(100px);*/
            transform:translateY(-100px) rotateX(90deg);
        }
        .box1 .child1:nth-child(2){
            background: rgba(0,145,100,0.4);
            /*transform:rotateY(-90deg) translateZ(100px);*/
            transform:translateX(-100px) rotateY(-90deg);
        }
        .box1 .child1:nth-child(3){
            background: rgba(100,45,230,0.4);
            /*transform:rotateY(90deg) translateZ(100px);*/
            transform:translateX(100px) rotateY(90deg);
        }

        .box1 .child1:nth-child(4){
            background: rgba(200,145,45,0.4);
            /*transform:rotateX(-90deg) translateZ(100px);*/
            transform:translateY(100px) rotateX(-90deg);
        }
        .box1 .child1:nth-child(5){
            background: rgba(150,0,70,0.4);
            transform:translateZ(100px);
        }
        .box1 .child1:nth-child(6){
            background: rgba(160,145,60,0.4);
            /*transform:rotateX(180deg) translateZ(100px);*/
            transform:translateZ(-100px) rotateY(180deg);
        }
          


        .box1:hover .child1:nth-child(1){
            background: rgba(45,145,230,0.4);
            /*transform:rotateX(90deg) translateZ(100px);*/
            transform:translateY(-200px) rotateX(90deg);
        }
        .box1:hover .child1:nth-child(2){
            background: rgba(0,145,100,0.4);
            /*transform:rotateY(-90deg) translateZ(100px);*/
            transform:translateX(-200px) rotateY(-90deg);
        }
        .box1:hover .child1:nth-child(3){
            background: rgba(100,45,230,0.4);
            /*transform:rotateY(90deg) translateZ(100px);*/
            transform:translateX(200px) rotateY(90deg);
        }

        .box1:hover .child1:nth-child(4){
            background: rgba(200,145,45,0.4);
            /*transform:rotateX(-90deg) translateZ(100px);*/
            transform:translateY(200px) rotateX(-90deg);
        }
        .box1:hover .child1:nth-child(5){
            background: rgba(150,0,70,0.4);
            transform:translateZ(200px);
        }
        .box1:hover .child1:nth-child(6){
            background: rgba(160,145,60,0.4);
            /*transform:rotateX(180deg) translateZ(100px);*/
            transform:translateZ(-200px) rotateY(180deg);
        }



        .box2{
            width: 100px;
            height: 100px;
            position: absolute;
            /*绝对定位后就不是块元素了,可以模拟*/
            left: 0;
            right: 0;
            bottom: 0;
            top: 0;
            margin: auto;
            transform:rotate3d(1,1,0,0deg);
            -webkit-transform-style:preserve-3d;

        }
        .box2 .child2{
            width: 100px;
            height: 100px;
            text-align: center;
            line-height:100px;
            font-size: 2em;
            position: absolute;
            
        }
        .box2 .child2:nth-child(1){
            background: rgba(45,145,230,0.4);
            /*transform:rotateX(90deg) translateZ(100px);*/
            transform:translateY(-50px) rotateX(90deg);
        }
        .box2 .child2:nth-child(2){
            background: rgba(0,145,100,0.4);
            /*transform:rotateY(-90deg) translateZ(100px);*/
            transform:translateX(-50px) rotateY(-90deg);
        }
        .box2 .child2:nth-child(3){
            background: rgba(100,45,230,0.4);
            /*transform:rotateY(90deg) translateZ(100px);*/
            transform:translateX(50px) rotateY(90deg);
        }

        .box2 .child2:nth-child(4){
            background: rgba(200,145,45,0.4);
            /*transform:rotateX(-90deg) translateZ(100px);*/
            transform:translateY(50px) rotateX(-90deg);
        }
        .box2 .child2:nth-child(5){
            background: rgba(150,0,70,0.4);
            transform:translateZ(50px);
        }
        .box2 .child2:nth-child(6){
            background: rgba(160,145,60,0.4);
            /*transform:rotateX(180deg) translateZ(100px);*/
            transform:translateZ(-50px) rotateY(180deg);
        }
    </style>
</head>
<body>
<div class="box1">
    <div class="child1">top</div>
    <div class="child1">left</div>
    <div class="child1">right</div>
    <div class="child1">btm</div>
    <div class="child1">face</div>
    <div class="child1">back</div>
    <div class="box2">
    	<div class="child2">top</div>
        <div class="child2">left</div>
        <div class="child2">right</div>
        <div class="child2">btm</div>
        <div class="child2">face</div>
        <div class="child2">back</div>
    </div>
</div>
</body>
</html>

标签:两个,translateZ,90deg,100px,transform,旋转,rgba,0.4,立方体
来源: https://blog.csdn.net/maxiaoxin1314/article/details/89930161

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有