-
Notifications
You must be signed in to change notification settings - Fork 0
/
colorfulHearts.html
31 lines (29 loc) · 972 Bytes
/
colorfulHearts.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
<!-- Help me to fix the bug -->
<!-- after stopping mouse cursor the heart is dispalyed one time again on the path of my move movement -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Colorful Hearts on Mousemove</title>
<link rel="stylesheet" href="heartstyle.css">
</head>
<body>
<script type="text/javascript">
document.addEventListener("mousemove", function(e){
var body = document.querySelector("body");
var heart = document.createElement("span");
var x = e.offsetX;
var y = e.offsetY;
heart.style.left = x + 'px';
heart.style.top = y + 'px';
var size = Math.random() * 90;
heart.style.width = size + "px";
heart.style.height = size + "px";
body.appendChild(heart);
setTimeout(function(){
heart.remove();
},2000);
});
</script>
</body>
</html>