• css吃豆豆动画


    在这里插入图片描述

    DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Documenttitle>
        <style>
            .box{
                width: 700px;height: 200px;
                /* background: pink; */
                margin: 100px auto;
                position: relative;
            }
            .eat{
                width: 200px;height: 200px;
                /* background: red; */
                border-radius: 50%;
                overflow: hidden;
                position: relative;
                z-index: 2;
            }
            .eat::before{
                content: "";
                /* 伪元素类似于span */
                /* 需要转为块元素才能设置宽高 */
                display: block;
                width: 200px;height: 100px;
                background: tomato;
                /* 旋转中心 */
                transform-origin: bottom center;
                transform: rotate(0deg);
                animation: rotate1 .4s ease infinite alternate;
            }
            .eat::after{
                content: "";
                display: block;
                width: 200px;height: 100px;
                background: tomato;
                transform-origin: top center;
                transform: rotate(30deg);
                /* alternate 动画在奇数次(1、3、5...)正向播放,在偶数次(2、4、6...)反向播放 */
                animation: rotate2 .4s ease infinite alternate;
            }
            .eye{
                width: 20px;height: 20px;
                background: #000;
                border: 2px solid #fff;
                border-radius: 50%;
                position: absolute;
                top:30px;left: 100px;
            }
            .peas{
                width: 40px;height: 40px;
                background: tomato;
                border-radius: 50%;
                position: absolute;
                top: calc(50% - 20px);
                /* transform: translateY(-20px); */
                left: 140px;
                /* 利用阴影多制造几个豆豆 */
                /* box-shadow: 水平阴影的位置 垂直阴影的位置 模糊距离 阴影的颜色 */
                box-shadow: 80px 0px 0px tomato,160px 0px 0px tomato,240px 0px 0px tomato,320px 0px 0px tomato,400px 0px 0px tomato,480px 0 0 tomato;
                animation: move .8s infinite;
            }
            /* 动画 */
            @keyframes rotate1 {
                0%{transform: rotate(0deg);}
                100%{transform: rotate(-30deg);}
            }
            @keyframes rotate2 {
                0%{transform: rotate(0deg);}
                100%{transform: rotate(30deg);}
            }
            @keyframes move {
                0%{transform: translateX(0);}
                100%{transform: translateX(-80px);}
            }
        style>
    head>
    <body>
        <div class="box">
            <div class="eat">
                <div class="eye">div>
            div>
            <div class="peas">div>
        div>
    body>
    html>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
  • 相关阅读:
    JS中跳转传参的几种方法
    maven pom文件通过profile配置多环境开发学习
    执行npm的时候报权限问题的解决方案
    golang工程——常用数据结构底层原理【mao、slice、func、string】
    【MATLAB GUI】 5. 图像处理菜单(菜单编辑器)
    从Flink的Kafka消费者看算子联合列表状态的使用
    [Python] OSError: [E050] Can‘t find model ‘en_core_web_sm‘.
    玻璃表面修饰DNA|DNA修饰的上转换纳米材料|DNA-UCNPs实验原理
    CSS元素浮动
    小白终于解决了在学习Go中不知道Makefile是什么的难题
  • 原文地址:https://blog.csdn.net/weixin_64729620/article/details/133966280