-
Notifications
You must be signed in to change notification settings - Fork 0
/
i2.html
100 lines (100 loc) · 2.24 KB
/
i2.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
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<!--感谢源作者大佬提供的demo学习 仅供代码学习与参考 源作者出处:二改自https://gitee.com/wyanhui02/html_css_demo/blob/master/html/11.html-->
<title>跳动爱心源码 作者:by冷夜</title>
<style>
body{
/*椭圆矩形属性*/
margin: 0;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
/* 背景径向渐变 */
background: radial-gradient(circle at center,mediumpurple,#000);
}
.heart{
width: 280px;
height: 220px;
display: flex;
justify-content: space-between;
}
.heart span{
/* 自定义属性值*/
--c:plum;
--h:50%;
--t:25%;
/* var()函数用于插入自定义的属性值,如果一个属性值在多处被使用,该方法就很有用 */
background-color: var(--c);
width: 20px;
border-radius: 10px;
position: relative;
height: var(--h);
top: var(--t);
/* 执行动画 infinite是无限次播放 */
animation: beating 3s infinite;
}
.heart span:nth-child(1),
.heart span:nth-child(9){
--c:lightcoral;
--h:60px;
--t:44px;
}
.heart span:nth-child(2),
.heart span:nth-child(8){
--c:lightskyblue;
--h:120px;
--t:12px;
}
.heart span:nth-child(3),
.heart span:nth-child(7){
--c:lightgreen;
--h:160px;
--t:0;
}
.heart span:nth-child(4),
.heart span:nth-child(6){
--c:gold;
--h:180px;
--t:16px;
}
.heart span:nth-child(5){
--c:plum;
--h:188px;
--t:32px;
}
/* 接下来我们定义动画 */
@keyframes beating{
0%,30%{
height: var(--h);
top: var(--t);
background-color: var(--c);
filter: blur(0);
}
60%,70%{
height: 50%;
top: 25%;
background-color: plum;
/* 模糊度 */
filter: blur(3px);
}
}
</style>
</head>
<body>
<div class="heart">
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
</div>
</body>
</html>