-
Notifications
You must be signed in to change notification settings - Fork 0
/
transforms.html
85 lines (77 loc) · 2.07 KB
/
transforms.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Individual Transforms: Mario</title>
<style>
* {
box-sizing: border-box;
}
:root {
--color1: #F17D28;
--color2: #F19C1B;
--color3: #ECD711;
--color4: #30BFBF;
--color5: #0799BA;
}
body {
position: relative;
height: 100vh;
margin: 0;
background: skyblue;
}
button {
font-size: 1.2em;
padding: .5em 1em;
}
/*Demo styles below*/
#mario {
width: 60px;
height: auto;
position: absolute;
top: 40%;
left: 5%;
animation: move 5s linear infinite;
transform-origin: bottom;
}
/* #mario.flip {
transform: rotateY(180deg);
} */
/* #mario.mushroom {
transform: scale(1.2);
} */
@keyframes move {
20% {
transform: translate(200px, 0px);
}
30% {
transform: translate(300px, -200px);
}
40% {
transform: translate(400px, 0px)
}
60%,
100% {
transform: translate(600px, 0);
}
}
</style>
</head>
<body>
<img id="mario" src="./assets/mario.webp" />
<button id="mushroom">Mushroom</button>
<button id="flip">Flip</button>
<script>
const mushroomBtn = document.getElementById('mushroom'), flipBtn = document.getElementById('flip'), mario = document.getElementById('mario');
mushroomBtn.addEventListener('click', growMario);
flipBtn.addEventListener('click', flipMario);
function growMario() {
mario.classList.toggle('mushroom');
}
function flipMario() {
mario.classList.toggle('flip');
}
</script>
</body>
</html>