CSS3多重背景结合动画打造会飘动的热气球

1、引入所需要的图片,分别定义他们的位置,其中background-position: x轴 y轴,x轴 y轴;注意要和图片一一对应。

2、添加动画与关键帧

布局:

 <div id="wrap">
        <h1>飞喽</h1>
        <div class="banner"></div>
    </div>

样式:

*{
            margin: 0;
            padding: 0;
        }
        #wrap{
            width: 90%;
            margin: 0 auto;
            padding: 1.25em;
        }
        h1{
            font-size: 2.5em;
            color: skyblue;
            text-align: center;
            margin: 1em 0;
        }
        .banner{
            width: 100%;
            min-width: 1200px;
            height: 280px;
            overflow: hidden;
            background: url(img/cloud-6.png), url(img/cloud-5.png),url(img/cloud-4.png), url(img/corel.png),
            url(img/cloud-3.png) , url(img/cloud-2.png) ,url(img/cloud-1.png), url(img/aws-bg.jpg);
            /* 分别定义图片的位置background-position: x轴 y轴,x轴 y轴; */
            background-position: 180% 100px,120% 110px,-350px 50px,5px 1%,120% -40px,10% 10px, 90% 10px,0 0;
            background-size: 70%,60%,65%,5%,40%,30%,30%,100%;
            background-repeat: no-repeat;
            animation: ship 7s ease-in forwards;
        }
        @keyframes ship {
            0%{
                /* 第四个为热气球的位置 */
                background-position-x: 150%, 120%, -350px, 5px, 120%, 10%, 90%, 0px;
                background-position-y: 100px, 110px, 50px, 100%, -40px, 10px, 10px, 0px;
            }
            100%{
                background-position-x: 200%, 150%, -500px, 1800px, 130%, 0%, 100%, 0px;
                background-position-y: 100px, 110px, 50px, 1%, -40px, 10px, 10px, 0px;
            }
        }

查看:

热气球.gif

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值