CSS动画奔跑的小熊

 效果(背景可无缝衔接循环)

 79ef83d29dd4419d85691a9274891bf0.gif

 

素材

通过百度网盘分享的文件:media
链接:https://pan.baidu.com/s/17uPWHlNcXUaoAr60SIG-5g?pwd=bear 
提取码:bear
复制这段内容打开「百度网盘APP 即可获取」

 

<!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>
    <link rel="stylesheet" href="奔跑的熊熊.css">
</head>
<body>    
    <div class="bg1"></div>
    <div class="bg2"></div>
    <div class="bear"></div>   
</body>
</html>

 

* {
    padding: 0;
    margin: 0;
}

body,
html {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.bg1,
.bg2 {
    height: 100%;
    width: 11220px; 
}

body {
    position: relative;
    background-color: rgba(140, 143, 183, 0.599);
}

.bg1 {
    position: absolute;
    z-index: 2;
    background: url(../media/bg1.png) repeat-x bottom;
    animation: bg1 25s linear infinite;   
}
.bg2 {
    position: absolute;
    z-index: 1;
    background: url(../media/bg2.png) repeat-x bottom;
    animation: bg2 40s linear infinite;
}

.bear {
    position: absolute;
    bottom: 30px;
    margin-left: -100px;
    z-index: 3;
    height: 100px;
    width: 200px;
    background: url(../media/bear.png) no-repeat;
    animation: bearMove linear 5s forwards,
               bear 1s steps(8) infinite ;
    
}

@keyframes bearMove {
    0% {
        left: 0;
    }
    100% {
        left: 50%;
    }
}

@keyframes bear {
    0% {
        background-position: 0;
    }
    100% {
        background-position: -1600px;
    }
}

@keyframes bg1 {
    0% {
        left: 0;
    }
    100% {
        left: -3840px;
    }
}

@keyframes bg2 {
    0% {
        left: 0;
    }
    100% {
        left: -3840px;
    }
}

遇到的问题

雪山背景的宽度用百分比表示,动画播放一次卡顿一下,衔接不流畅。
 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值