zoukankan      html  css  js  c++  java
  • 3D立体效果

    效果图看左上角

    代码如下:

    <!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>

    个人学习,内容简略。

  • 相关阅读:
    java的类继承(与c++对比)
    java的数据类型、自动拆装箱、字面量
    java中关键字static和final
    JVM之JIT
    java之JIT(Just in time)
    栈和堆
    C++中vector的使用
    canvas
    ajax笔记
    CSS笔记
  • 原文地址:https://www.cnblogs.com/2979100039-qq-con/p/13367091.html
Copyright © 2011-2022 走看看