手记

C3-简单实现立方体+旋转+特效

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            .container{
                width: 500px;
                margin: 50px auto;
            }
            .cub{
                position: relative;
                width: 100px;
                height: 100px;
                transform-style: preserve-3d;
                -webkit-transform-style: preserve-3d;
                transition: all 5s linear;
            }
            .cub div{
                width: 100px;
                height: 100px;
                position: absolute;
                left: 0;
                top: 0;
                transform-style: preserve-3d;
                -webkit-transform-style: preserve-3d;
                border: 1px solid #46B8DA;
                opacity: 0.5;
            }
            .one{
                transform: rotateY(0deg) translateZ(50px);
            }
            .two{
                transform: rotateY(180deg) translateZ(50px);
            }
            .three{
                transform: rotateX(90deg) translateZ(50px);
            }
            .four{
                transform: rotateX(-90deg) translateZ(50px);
            }
            .five{
                transform: rotateY(90deg) translateZ(50px);
            }
            .six{
                transform: rotateY(-90deg) translateZ(50px);
            }
            .cub:hover{
                transform: rotateX(360deg) rotateY(360deg);
                -webkit-transform: rotateX(360deg) rotateY(360deg);
            }

            .cub:hover .one{
                transform: rotateY(0deg) translateZ(100px);
            }
            .cub:hover .two{
                transform: rotateY(180deg) translateZ(100px);
            }
            .cub:hover .three{
                transform: rotateX(90deg) translateZ(100px);
            }
            .cub:hover .four{
                transform: rotateX(-90deg) translateZ(100px);
            }
            .cub:hover .five{
                transform: rotateY(90deg) translateZ(100px);
            }
            .cub:hover .six{
                transform: rotateY(-90deg) translateZ(100px);
            }
        </style>
    </head>
    <body>
        <div class="container">
            <div class="cub">
                <div class="one" ></div>
                <div class="two" ></div>
                <div class="three" ></div>
                <div class="four" ></div>
                <div class="five" ></div>
                <div class="six" ></div>
            </div>
        </div>
    </body>
</html>
15人推荐
随时随地看视频
慕课网APP