3D旋转木马案例

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            perspective: 600px;
        }
        
        section {
            position: relative;
            width: 300px;
            height: 200px;
            margin: 300px auto;
            transform-style: preserve-3d;
            background: url(media/pig.jpg)no-repeat;
            /* animation: name duration timing-function delay iteration-count direction fill-mode; */
            /* 动画名称,执行时间,匀速播放,循环 */
            animation: ook 10s linear infinite;
        }
        
        section div {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: url(media/dog.jpg)no-repeat;
        }
        
        section:hover {
            animation-play-state: paused;
        }
        
        @keyframes ook {
            0% {
                transform: rotateY(0);
            }
            100% {
                transform: rotateY(360deg);
            }
        }
        
        section div:nth-child(1) {
            transform: translateZ(300px);
        }
        
        section div:nth-child(2) {
            transform: rotateY(60deg) translateZ(300px);
        }
        
        section div:nth-child(3) {
            transform: rotateY(120deg) translateZ(300px);
        }
        
        section div:nth-child(4) {
            transform: rotateY(180deg) translateZ(300px);
        }
        
        section div:nth-child(5) {
            transform: rotateY(240deg) translateZ(300px);
        }
        
        section div:nth-child(6) {
            transform: rotateY(300deg) translateZ(300px);
        }
    </style>
</head>

<body>
    <section>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </section>
</body>

</html>

在这里插入图片描述

发布了68 篇原创文章 · 获赞 1 · 访问量 1012

猜你喜欢

转载自blog.csdn.net/weixin_42378409/article/details/105118479