hooyantsing's Blog

P220_12_我心动了

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

P220 12 我心动了

实战案例

介绍:跳动的心,无限循环动画。

效果:

e6c58f503237e2214d53547b47233d35.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
79
80
81
82
83
<!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 {
            width: 200px;
            height: 200px;
            background: #e74c3c;
            position: relative;
            transform: rotate(45deg);
            animation-name: hd;
            animation-duration: 2s;
            animation-iteration-count: infinite;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        main::before {
            content: '';
            width: 200px;
            height: 200px;
            background: #e74c3c;
            border-radius: 50%;
            position: absolute;
            transform: translateX(-50%);
        }

        main::after {
            content: '';
            width: 200px;
            height: 200px;
            background: #e74c3c;
            border-radius: 50%;
            position: absolute;
            transform: translateY(-50%);
        }

        @keyframes hd {
            25% {
                transform: rotate(45deg) scale(.5);
                opacity: .5;
            }
            50% {
                transform: rotate(45deg) scale(1);
                opacity: 1;
            }
            75% {
                transform: rotate(45deg) scale(.5);
                opacity: .5;
            }
        }

        p {
            position: absolute;
            font-size: 24px;
            z-index: 1;
            transform: rotate(-45deg);
        }
    </style>
</head>
<body>
<main>
    <p></p>
</main>
</body>
</html>
CATALOG