CSS:吃豆子动画

主要用到了CSS3动画以及CSS3 转换。

代码如下:

 

<!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>
        .box {
            margin: 50px 50px;
            position: relative;
            width: 350px;
            height: 200px;
        }
        .head {
            position: relative;
            width: 200px;
            height: 200px;
            background-color: white;
            border-radius: 50%;
            overflow: hidden;
        }
        .head::before,
        .head::after {
            position: absolute;
            z-index: 1;
            left: 0;
            content: '';
            width: 200px;
            height: 100px;
            background-color: orangered;
        }
        .head::before {
            top: 0;
            transform-origin: 100px 100px;
            animation: top .5s linear infinite alternate;
        }
        .head::after {
            top: 100px;
            transform-origin: 100px 0px;
            animation: bottom .5s linear infinite alternate ;
        }
        .dot {
            position: absolute;
            left: 100px;
            top: 50%;
            transform: translateY(-50%);
            width: 15px;
            height: 15px;
            border-radius: 50%;
            background-color: red;
            box-shadow: 50px 0 0 orange, 100px 0 0 orange, 150px 0 0 orange,200px 0 0 orange;
            animation: eat .5s linear infinite;
        }
        @keyframes top {
            0% {
                transform: rotate(-30deg);
            }
            100% {
                transform: rotate(0deg);
            }
        }
        @keyframes bottom {
            0% {
                transform: rotate(30deg);
            }
            100% {
                transform: rotate(0deg);
            }
        }
        @keyframes eat {
            100% {
                left: 0;
            }
        }
    </style>
</head>
<body>
        <div class="box">
            <div class="head"></div>
            <div class="dot"></div>
        </div>
</body>
</html>

效果图:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值