码迷,mamicode.com
首页 > 其他好文 > 详细

3D立体效果

时间:2021-01-11 11:09:41      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:inf   sla   lin   --   :hover   立方体   pre   animation   style   

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>基于CSS3的3D立方体旋转动画</title>
        <style>
            /* 3d旋转样式 */
            .cub {
                width: 2.5rem;
                height: 2.5rem;
                position: fixed;
                left: 3%;
                top: 3.75rem;
            }

            #cube {
                animation: 6s spin linear infinite;
                height: 100%;
                position: absolute;
                transform-style: preserve-3d;
                width: 100%;
            }

            #cube * {
                display: block;
                height: 2.5rem;
                position: absolute;
                width: 2.5rem;
                cursor: pointer;
            }

            .cub:hover {
                width: 6.25rem;
                height: 6.25rem;
            }

            .cub:hover #cube * {
                width: 6.25rem;
                height: 6.25rem;
            }

            #cube *:before {
                content: ‘‘;
                height: 100%;
                position: absolute;
                width: 100%;
            }

            .cub:hover #back {
                transform: rotateX(180deg) translateZ(5rem);
            }

            .cub:hover #front {
                transform: rotateY(0deg) translateZ(5rem);
            }

            .cub:hover #bottom {
                transform: rotateX(-90deg) translateZ(5rem);
            }

            .cub:hover #left {
                transform: rotateY(-90deg) translateZ(5rem);
            }

            .cub:hover #right {
                transform: rotateY(90deg) translateZ(5rem);
            }

            .cub:hover #top {
                transform: rotateX(90deg) translateZ(5rem);
            }

            /*  */

            #back {
                transform: rotateX(180deg) translateZ(1.875rem);
            }

            #front {
                transform: rotateY(0deg) translateZ(1.875rem);
            }

            #bottom {
                transform: rotateX(-90deg) translateZ(1.875rem);
            }

            #left {
                transform: rotateY(-90deg) translateZ(1.875rem);
            }

            #right {
                transform: rotateY(90deg) translateZ(1.875rem);
            }

            #top {
                transform: rotateX(90deg) translateZ(1.875rem);
            }

            @keyframes spin {
                0% {
                    transform: translateZ(6.25rem) rotateX(0) rotateY(0deg);
                }

                100% {
                    transform: translateZ(6.25rem) rotateX(360deg) rotateY(360deg);
                }
            }
        </style>
    </head>

    <body>
        <!-- 3d旋转图片div -->
        <div class="cub">
            <ul id="cube">
                <li id="back">
                    <img src=" ">
                </li>
                <li id="bottom">
                    <img src=" ">
                </li>
                <li id="front">
                    <img src=" ">
                </li>
                <li id="left">
                    <img src=" ">
                </li>
                <li id="right">
                    <img src=" ">
                </li>
                <li id="top">
                    <img src=" ">
                </li>
            </ul>
        </div>

    </body>
</html>

  

https://www.cnblogs.com/2979100039-qq-con/p/13367091.html

3D立体效果

标签:inf   sla   lin   --   :hover   立方体   pre   animation   style   

原文地址:https://www.cnblogs.com/brady-wang/p/14252097.html

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