image.png

    1. <style>
    2. body{
    3. perspective: 500px;
    4. }
    5. img{
    6. display: block;
    7. margin: 100px auto;
    8. transition: all 5s;
    9. }
    10. img:hover{
    11. /* 第一种写法 */
    12. transform: rotateX(360deg);
    13. /* 第二种写法 */
    14. transform: rotate3d(1,0,0,360deg);
    15. }
    16. </style>
    17. <body>
    18. <img src="../HTML5+CSS3/media/pig.jpg" alt="">
    19. </body>

    image.png
    image.png
    image.png
    image.png
    3D呈现 transfrom-style
    transfrom-style:preserve-3d:子元素开启立体空间
    image.png

    <style>
        .box{
            position: relative;
            width: 200px;
            height: 200px;
            margin: 100px auto;
            background-color: khaki;
            perspective: 500px;
            transition: all 1s;
            transform-style:preserve-3d ;
        }
        .box:hover{
            transform: rotateY(60deg);
        }
        .box div{
            position: absolute;
            top:0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: aquamarine;
        }
        .box div:last-child{
            background-color: green;
            transform: rotateX(60deg);
        }
    </style>
    <body>
        <div class="box">
            <div></div>
            <div></div>
        </div>
    </body>
    

    image.png
    image.png