利用CSS3动画制作“百度浏览器”官网奔跑的北极熊

1 篇文章 0 订阅

效果图:

素材及代码:

https://474b.com/f/1445568-484420276-75767d
(访问密码:5719)

<!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>
        * {
            margin: 0;
            padding: 0;
        }

        .bg1 {
            position: absolute;
            width: 1920px;
            height: 600px;
            top: 200px;
            background: url(images/bg1.png) no-repeat;
            animation: move_bg 50s linear infinite;
        }

        .bg2 {
            top: 600px;
            width: 1920px;
            height: 600px;
            background: url(images/bg2.png) no-repeat;
            animation: move_bg 80s linear infinite;
        }

        .bear {
            position: absolute;
            top: 400px;
            width: 200px;
            height: 100px;
            background: url(images/bear.png) no-repeat;
            animation: bear 1s steps(8) infinite, move 1s forwards;
            z-index: 1;
        }

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

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

        @keyframes move {
            0% {
                left: 0;
            }

            100% {
                left: 50%;
                /* margin-left: -100px; */
                transform: translateX(-50%);
            }
        }

        @keyframes move_bg {
            0% {
                background-position: 0 0;
            }

            100% {
                background-position: 100% 0;
            }
        }
    </style>
</head>

<body>
    <div class="bear"></div>
    <div class="bg1"></div>
    <div class="bg2"></div>
</body>

</html>

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值