-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6_togglelight.html
More file actions
53 lines (46 loc) · 1.09 KB
/
Copy path6_togglelight.html
File metadata and controls
53 lines (46 loc) · 1.09 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Toggle Light</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #f0f0f0;
}
#lightBulb {
width: 120px;
height: 120px;
background-color: grey;
border-radius: 50%;
margin: 20px;
box-shadow: 0 0 10px rgba(0,0,0,0.3);
transition: background-color 0.3s, box-shadow 0.3s;
}
#lightBulb.on {
background-color: yellow;
box-shadow: 0 0 30px yellow;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
</style>
</head>
<body>
<button id="toggleBtn">Toggle Light</button>
<div id="lightBulb"></div>
<script>
const button = document.getElementById("toggleBtn");
const bulb = document.getElementById("lightBulb");
button.addEventListener("click", () => {
bulb.classList.toggle("on");
});
</script>
</body>
</html>