-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
51 lines (45 loc) · 1.07 KB
/
index.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
<!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>Twitter Like with Sprites</title>
<style>
body {
height: 100vh;
margin: 0;
display: flex;
align-items: center;
justify-content: center;
}
.like {
width: 50px;
height: 50px;
background-image: url(img/heart_sprite.png);
background-size: 1450px 50px;
cursor: pointer;
}
.is-liked {
animation: like 0.8s steps(28) forwards;
}
@keyframes like {
0% {
background-position: 0 0;
}
100% {
background-position: right;
}
}
</style>
</head>
<body>
<div class="like" id="like"></div>
<script>
const like = document.getElementById('like');
like.addEventListener('click', e => {
like.classList.toggle('is-liked');
});
</script>
</body>
</html>