Skip to content

Commit 6c7440e

Browse files
committed
跳动的小爱心
1 parent f917194 commit 6c7440e

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

‎CSS跳动爱心/index.html‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>跳动的小爱心</title>
8+
</head>
9+
<body>
10+
<div class="heart"></div>
11+
</body>
12+
<style>
13+
/* 设置一个初始的宽高 */
14+
html,body {
15+
width: 100%;
16+
height: 100%;
17+
}
18+
/* 给body初始化一些样式,并且设置为flex盒子 */
19+
body {
20+
margin: 0;
21+
display: flex;
22+
justify-content: center;
23+
align-items: center;
24+
background-color: rgb(190, 153, 153);
25+
}
26+
/* 给我们的爱心设置一下样式,并且初始化动画 */
27+
.heart {
28+
width: 60px;
29+
height: 60px;
30+
background-color: rgb(221, 35, 35);
31+
position: relative;
32+
animation: beat .6s infinite ease-in;
33+
}
34+
/* 利用为元素,分别添加两个圆,为了看出差别,颜色先不一样*/
35+
.heart:before,.heart:after{
36+
content: '';
37+
position: absolute;
38+
width: 60px;
39+
height: 60px;
40+
background-color: rgb(221, 35, 35);
41+
border-radius: 50%;
42+
}
43+
/* 设置两个伪元素的位置 */
44+
.heart:before{
45+
left: 30px;
46+
}
47+
.heart:after {
48+
top: -30px;
49+
}
50+
/* 定义beat动画 */
51+
@keyframes beat {
52+
0%{
53+
transform:scale(1) rotate(-45deg);
54+
}
55+
56+
40%{
57+
transform:scale(1) rotate(-45deg);
58+
}
59+
60+
55%{
61+
transform:scale(1.3) rotate(-30deg);
62+
}
63+
64+
70%{
65+
transform:scale(1) rotate(-45deg);
66+
}
67+
68+
85%{
69+
transform:scale(1.3) rotate(-60deg);
70+
}
71+
72+
100%{
73+
transform:scale(1) rotate(-45deg);
74+
}
75+
}
76+
</style>
77+
</html>

0 commit comments

Comments
 (0)