-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path15. Bulb.html
More file actions
101 lines (90 loc) · 2.98 KB
/
Copy path15. Bulb.html
File metadata and controls
101 lines (90 loc) · 2.98 KB
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
99
100
101
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Creative Light Toggle</title>
<style>
/* CSS - The Design */
body {
background-color: #1a1a1a; /* Dark room effect */
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
font-family: 'Arial', sans-serif;
transition: background 0.4s ease;
}
.bulb-container {
position: relative;
margin-bottom: 50px;
}
#bulb {
width: 150px;
cursor: pointer;
filter: grayscale(1); /* Looks "dead" when off */
transition: all 0.3s ease;
z-index: 2;
}
/* The "Glow" effect when the bulb is on */
.on #bulb {
filter: grayscale(0) drop-shadow(0 0 60px rgba(255, 230, 0, 0.8));
}
.on {
background-color: #2c2c2c; /* Lightens the room slightly */
}
/* The Switch Button */
#toggleBtn {
padding: 15px 50px;
font-size: 18px;
font-weight: bold;
text-transform: uppercase;
border: none;
border-radius: 50px;
cursor: pointer;
background-color: #444;
color: white;
box-shadow: 0 5px 15px rgba(0,0,0,0.5);
transition: 0.2s;
}
#toggleBtn:active {
transform: translateY(4px);
}
.btn-on {
background-color: #f1c40f !important;
color: #000 !important;
box-shadow: 0 0 20px rgba(241, 196, 15, 0.4) !important;
}
</style>
</head>
<body id="room">
<div class="bulb-container">
<img id="bulb" src="https://i.postimg.cc/6Qy9YQ90/light-bulb-off.png" alt="Light Bulb">
</div>
<button id="toggleBtn" onclick="toggleLight()">Turn On</button>
<script>
// JavaScript - The Logic
function toggleLight() {
const bulb = document.getElementById('bulb');
const btn = document.getElementById('toggleBtn');
const room = document.getElementById('room');
// Toggle logic using the image source
if (bulb.src.match("off")) {
// Change to ON
bulb.src = "Bulb Photo/on.png";
room.classList.add('on');
btn.classList.add('btn-on');
btn.innerHTML = "Turn Off";
} else {
// Change to OFF
bulb.src = "Bulb Photo/off.png";
room.classList.remove('on');
btn.classList.remove('btn-on');
btn.innerHTML = "Turn On";
}
}
</script>
</body>
</html>