Skip to content

Commit 22577c7

Browse files
Merge pull request #1136 from AmethystDev2713/PopTheBubbles-AmethystDev2713-branch
Add a project called "Pop The Bubbles"
2 parents 93e28f2 + db48757 commit 22577c7

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<html>
2+
<head>
3+
<title>Pop The Bubbles!</title>
4+
<meta charset="UTF-8"/>
5+
<script>
6+
var layer = 0;
7+
var count = 0;
8+
setInterval(function() {
9+
var newBubble = document.createElement("div");
10+
newBubble.style.position = "absolute";
11+
newBubble.style.marginLeft = (Math.floor(Math.random() * (window.innerWidth)) + 1) + "px";
12+
newBubble.style.marginTop = (Math.floor(Math.random() * (window.innerHeight)) + 1) + "px";
13+
newBubble.style.height = "24px";
14+
newBubble.style.width = "24px";
15+
newBubble.style.border = "1px solid DodgerBlue";
16+
newBubble.style.borderRadius = "24px";
17+
newBubble.style.backgroundColor = "DodgerBlue";
18+
layer += 1;
19+
newBubble.style.zIndex = layer;
20+
document.body.appendChild(newBubble);
21+
count += 1;
22+
document.getElementById("count").innerHTML = count;
23+
newBubble.onclick = function() {
24+
newBubble.innerHTML = "POP!";
25+
newBubble.style.border = "none";
26+
newBubble.style.backgroundColor = "";
27+
count -= 1;
28+
}
29+
}, 200);
30+
</script>
31+
</head>
32+
<body style="position: relative;">
33+
<div>Bubbles! There are currently <span id="count">0</span> bubbles on the screen. Click a bubble to pop it</div>
34+
</body>
35+
</html>
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Pop The Bubbles!
2+
3+
A fun little JavaScript demo. 5 bubbles will spawn every second, and you can click on one to pop it. Can you pop them all?
4+
5+
![Screenshot](https://raw.githubusercontent.com/AmethystDev2713/javascript-mini-projects/PopTheBubbles-AmethystDev2713-branch/PopTheBubbles/AmethystDev2713/image.png)
40.9 KB
Loading

0 commit comments

Comments
 (0)