旋转木马css动画

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

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            background-color: cadetblue;
        }
        .box {
            position: relative;
            width: 300px;
            height: 200px;
            margin: 160px auto;
            perspective: 25000px;
            transform-style: preserve-3d;
            animation: rotate 10s linear infinite;
            background-image: url(https://img2.baidu.com/it/u=2161071795,3577630275&fm=26&fmt=auto);
            background-size: 100% 100%;
        }
        
        .box:hover {
            animation-play-state: paused;
        }
        
        .img {
            position: absolute;
            left: 0;
            top: 0;
            width: 300px;
            height: 200px;
            background: url('./tiger.jpg');
        }
        
        .box .img:nth-child(1) {
            transform: rotateY(0) translateZ(300px);
            background-color: darkorchid;
        }
        
        .box .img:nth-child(2) {
            transform: rotateY(60deg) translateZ(300px);
            background-color: darkgoldenrod;
        }
        
        .box .img:nth-child(3) {
            transform: rotateY(120deg) translateZ(300px);
            background-color: salmon;
        }
        
        .box .img:nth-child(4) {
            transform: rotateY(180deg) translateZ(300px);
            background-color: blue;
        }
        
        .box .img:nth-child(5) {
            transform: rotateY(240deg) translateZ(300px);
            background-color: rosybrown;
        }
        
        .box .img:nth-child(6) {
            transform: rotateY(300deg) translateZ(300px);
            background-color: burlywood;
        }
        
        @keyframes rotate {
            0% {
                transform: rotateY(0);
            }
            100% {
                transform: rotateY(360deg);
            }
        }
    </style>
</head>

<body>
    <div class="box">

        <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg2.baidu.com%2Fit%2Fu%3D203943576%2C2914045910%26fm%3D253%26app%3D120%26f%3DJPEG%3Fw%3D1200%26h%3D578&refer=http%3A%2F%2Fimg2.baidu.com&app=2002&size=w300&q=a80&n=0&g=0n&fmt=jpeg?sec=1645232285&t=aad1cbeda94024f65965d757f88a3e16" alt="" class="img">

        <img src="https://img1.baidu.com/it/u=2344258091,2248795866&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=313" alt="" class="img">

        <img src="https://img0.baidu.com/it/u=4142007859,2009814155&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=352" alt="" class="img">

        <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg1.baidu.com%2Fit%2Fu%3D1207938889%2C442335491%26fm%3D253%26app%3D120%26f%3DPNG%3Fw%3D800%26h%3D800&refer=http%3A%2F%2Fimg1.baidu.com&app=2002&size=w300&q=a80&n=0&g=0n&fmt=jpeg?sec=1645231810&t=cfc9cded108f1ea59e7e1fc4485007d3" alt="" class="img">

        <img src="https://img1.baidu.com/it/u=2344258091,2248795866&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=313" alt="" class="img">

        <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg1.baidu.com%2Fit%2Fu%3D173306754%2C3418888243%26fm%3D253%26app%3D120%26f%3DJPEG%3Fw%3D1131%26h%3D800&refer=http%3A%2F%2Fimg1.baidu.com&app=2002&size=w300&q=a80&n=0&g=0n&fmt=jpeg?sec=1645231810&t=844b075a5307d34e1f40e1aac19ec28a" alt="" class="img">

    </div>
</body>

</html>

重点属性:

perspective

transform-style

animation

animation-play-state

transform: rotateY(0) translateZ(300px);

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值