forked from hariom1616/Tech-Inventory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HAcked fun.html
98 lines (87 loc) · 2.77 KB
/
HAcked fun.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
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Enhanced Recursive Box Interface</title>
<style>
:root {
--main-color: #3498db;
--hover-color: #2980b9;
--new-box-color: #e74c3c;
--text-color: white;
}
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
font-family: Arial, sans-serif;
}
.box {
width: 200px;
height: 200px;
display: flex;
align-items: center;
justify-content: center;
background-color: var(--main-color);
color: var(--text-color);
cursor: pointer;
position: relative;
transition: transform 0.3s ease, background-color 0.3s ease;
overflow: hidden; /* Ensures content containment within each box */
border-radius: 10px;
}
.box:hover {
transform: scale(1.1);
background-color: var(--hover-color);
}
.new-box {
position: absolute;
width: 80%;
height: 80%;
top: 10%;
left: 10%;
background-color: var(--new-box-color);
display: flex;
align-items: center;
justify-content: center;
border-radius: 10px;
color: var(--text-color);
font-size: 0.9em;
cursor: pointer;
transition: background-color 0.3s ease, transform 0.3s ease;
}
.new-box:hover {
background-color: #c0392b;
transform: scale(1.05);
}
.box span {
font-size: 1.2em;
text-align: center;
}
</style>
</head>
<body>
<div class="box" aria-label="Opening Box" role="button" onclick="openNewBox(this)">
<span>Open Me</span>
</div>
<script>
let boxCount = 1; // Counter for opened boxes
function openNewBox(element) {
const newBox = document.createElement("div");
newBox.className = "box new-box";
newBox.innerHTML = `<span>Box ${++boxCount} opened!</span>`;
newBox.setAttribute("aria-label", `Opening Box ${boxCount}`);
newBox.onclick = function(event) {
event.stopPropagation(); // Stops event bubbling to prevent unintended recursion
openNewBox(this);
};
// Append new box inside the clicked box
element.appendChild(newBox);
}
</script>
</body>
</html>