Skip to content

Commit 4923c8f

Browse files
Merge pull request Nivedita-coder#14 from jishu-yadav/patch-1
Create JS animation
2 parents 67664b7 + f035afd commit 4923c8f

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎JS animation‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<style>
4+
#myContainer {
5+
width: 4000px;
6+
height: 4000px;
7+
background: green;
8+
}
9+
#myAnimation {
10+
width: 150px;
11+
height: 150px;
12+
position: absolute;
13+
background-color: yellow;
14+
}
15+
</style>
16+
<body>
17+
18+
<div id ="myContainer">
19+
<div id ="myAnimation"></div>
20+
</div>
21+
22+
<script>
23+
function myMove() {
24+
var elem = document.getElementById("myAnimation");
25+
var pos = 0;
26+
var id = setInterval(frame, 10);
27+
function frame() {
28+
if (pos == 350) {
29+
clearInterval(id);
30+
} else {
31+
pos++;
32+
elem.style.top = pos + 'px';
33+
elem.style.left = pos + 'px';
34+
}
35+
}
36+
}
37+
</script>
38+
39+
</body>
40+
</html>

0 commit comments

Comments
 (0)