-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheart.html
64 lines (64 loc) · 1.85 KB
/
heart.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>heart beats</title>
<style type="text/css">
.wrap{
width:400px;
margin: 200px auto 0;
}
.heart{
width: 200px;
height: 200px;
background: #f00;
position: relative;
filter:drop-shadow(0px 0px 20px rgb(255,20,20));
transform: rotate(45deg);
animation:heartbeat 1s linear infinite;
}
.heart:before, .heart:after{
content: "";
position: absolute;
width: 200px;
height: 200px;
background: #f00;
border-radius: 100px;
}
.heart:before{
left: -100px;
}
.heart:after{
left: 0;
top: -100px;
}
@keyframes heartbeat{
0%{transform: rotate(45deg) scale(0.8,0.8); opacity: 1;}
25%{transform: rotate(45deg) scale(1,1); opacity: 0.8;}
100%{transform: rotate(45deg) scale(0.8,0.8); opacity: 1;}
}
</style>
</head>
<body>
<div class="wrap">
<div class="heart"></div>
<input type="button" value="暂停" id="click"/>
</div>
<script type="text/javascript">
var heart = document.getElementsByClassName('heart')[0]
var button = document.getElementById('click')
button.addEventListener('click',function(){
var playstate = document.defaultView.getComputedStyle(heart, null).animationPlayState
if(playstate=="running"){
heart.style.animationPlayState = "paused"
this.value="运行"
}else{
heart.style.animationPlayState = "running"
this.value = "暂停"
}
},false)
</script>
</body>
</html>