hooyantsing's Blog

P223_15_弹跳小球体验动画轮换衔接

字数统计: 241阅读时长: 1 min
2020/04/24

P223 15 弹跳小球体验动画轮换衔接

实战案例

介绍:弹跳的乒乓球。

效果:

c956385b3807221669d43cb087eb9068.png

源码:

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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        body {
            height: 100vh;
            width: 100vw;
            display: flex;
            justify-content: center;
            align-items: center;
            background: #2c3e50;
        }

        main {
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        div {
            width: 100px;
            height: 100px;
            background: radial-gradient(at center, #e67e22, #e74c3c);
            border-radius: 50%;
            animation-name: jump;
            animation-duration: .6s;
            animation-iteration-count: infinite;
            animation-direction: alternate;
            animation-timing-function: ease-out;
        }

        @keyframes jump {
            to {
                transform: translateY(-300px);
            }
        }

        section {
            position: absolute;
            width: 300px;
            height: 40px;
            background: rgba(0, 0, 0, .3);
            bottom: -20px;
            border-radius: 50%;
            z-index: -1;
            filter: blur(5px);
            animation-name: shadow;
            animation-duration: .6s;
            animation-iteration-count: infinite;
            animation-direction: alternate;
            animation-timing-function: ease-out;
        }

        @keyframes shadow {
            to {
                width: 200px;
                height: 20px;
                background: rgba(0, 0, 0, .1);
                filter: blur(10px);
            }
        }
    </style>
</head>
<body>
<main>
    <div></div>
    <section></section>
</main>
</body>
</html>
CATALOG