CSS变形、动画实现的旋转魔方

2021-03-14 11:40

阅读:623

标签:ati   ora   doc   alt   图片   box   jpeg   orange   key   

DOCTYPE html>
html>
    head>
        meta charset="utf-8">
        title>魔方title>

        style type="text/css">
            body{
                height: 100vh;
                width: 100vw;
/*             background-image: url(../img/rubick.jpeg); */
                margin: 0;
                padding: 0;
            }
            #cube{
                width: 300px;
                height: 300px;
                position: absolute;
                top: 50%;
                margin-top: -150px;
                left: 50%;
                margin-left: -150px;
                transform-style: preserve-3d;
                animation: run 10s linear infinite;
            }
            
            #cube > div{
                width: 300px;
                height: 300px;
                position: absolute;
                opacity: 0.7;
            }
            
            #box1{
                background-color: green;
                transform:rotateX(90deg) translateZ(150px);
            }
            #box2{
                background-color: red;
                transform:rotateX(-90deg) translateZ(150px);
            }
            #box3{
                background-color: blue;
                transform:rotateY(90deg) translateZ(150px);
            }
            #box4{
                background-color: yellow;
                transform:rotateY(-90deg) translateZ(150px);
            }
            #box5{
                background-color: pink;
                transform:translateZ(-150px);
            }
            #box6{
                background-color: orange;
                transform:translateZ(150px);
            }
            
            @keyframes run{
                from{
                    transform: rotateX(0) rotateY(0);
                }
                to{
                    transform: rotateX(360deg) rotateY(360deg);
                }
            }
            
            div img{
                width: 300px;
                height: 300px;
            }
        style>
    head>
    
    body>
        div id="cube">
            div id="box1">
                img src="../img/1.jpg" >
            div>
            div id="box2">
                img src="../img/2.jpg" >
            div>
            div id="box3">
                img src="../img/3.jpg" >
            div>
            div id="box4">
                img src="../img/4.jpg" >
            div>
            div id="box5">
                img src="../img/5.jpg" >
            div>
            div id="box6">
                img src="../img/6.jpg" >
            div>
        div>
    body>
html>

效果图:

技术图片

 

CSS变形、动画实现的旋转魔方

标签:ati   ora   doc   alt   图片   box   jpeg   orange   key   

原文地址:https://www.cnblogs.com/lilisblog/p/12811448.html

上一篇:JSON的认识

下一篇:Hibernate框架


评论


亲,登录后才可以留言!