css旋转木马

通过 transfrom 和animation 来实现 旋转木马 注意图片的大小 和transfromz的值

<!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>
        /* 制作动画 ,让图片旋转  */
        @keyframes rotate {
            from{
                transform: rotateY(0);
            }
            to {
                transform: rotateY(360deg);
            }
            
        }
        /* 增添透视功能 */
        body{
            perspective: 1000px;
        }
    /* 进行定位,将盒子的宽高设置为图片的大小, 图片的大小会影响整体的选择效果  */
        section{
            position: relative;
            width: 500px;
            height: 313px;
            margin: 200px auto;  
            transform-style: preserve-3d;
            /*  设置动画属性 名称  时间  运动方式   无线循环*/
            animation: rotate  10s linear infinite;
        }
        section:hover{
            /* 增添鼠标放上暂停 */
            animation-play-state: paused;
        }
        section div{
            width: 100%;
            height: 100%;
            position: absolute;
            left: 0;
            top: 0;
            background: url(img/jpg/4.jpg) no-repeat;
            /* ,no-repeat 则不允许图像在任何方向上平铺。默认地,背景图像将从一个元素的左上角开始 */
        }

        /* 调整旋转的角度 和移动的位置  */
        section div:nth-last-child(1){
            transform: translateZ(500px);
        }
        section div:nth-last-child(2){
            transform:rotateY(60deg)  translateZ(500px)   ; 
        }
        section div:nth-last-child(3){
            transform:rotateY(120deg)    translateZ(500px); 
        } 
        section div:nth-last-child(4){
            transform:rotateY(180deg)    translateZ(500px); 
        }
        section div:nth-last-child(5){
            transform:rotateY(240deg)    translateZ(500px); 
        }
        section div:nth-last-child(6){
            transform:rotateY(300deg)    translateZ(500px); 
        }
        
    </style>
</head>
<body>
<section>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
</section>
</body>
</html>
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值