-
Notifications
You must be signed in to change notification settings - Fork 0
/
lightSlider.html
109 lines (96 loc) · 2 KB
/
lightSlider.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
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Light Slider</title>
<style>
body {
height: 100vh;
width: 100vw;
display: flex;
flex-direction: column;
text-align: center;
background: #ffb830;
padding: 0;
margin: 0;
color: #fff;
}
.wrap {
margin: auto;
}
.switch {
position: relative;
display: inline-block;
width: 250px;
height: 80px;
}
.switch input {
visibility: hidden;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #ffb830;
-webkit-transition: 0.4s;
transition: 0.4s;
box-shadow: -5px -5px 8px rgba(255, 255, 255, 0.2),
5px 5px 8px rgba(0, 0, 0, 0.2);
}
.slider:before {
position: absolute;
content: "";
height: 65px;
width: 65px;
background: #fff;
left: 4px;
bottom: 4px;
-webkit-transition: 0.5s;
transition: 0.5s;
}
input:checked+.slider {
background: #ff2442;
}
input:checked+.slider:before {
transform: translateX(177px);
}
.slider.round {
border-radius: 50px;
}
.slider.round:before {
border-radius: 50%;
}
.lights-on {
background: #ff2442;
width: 100vw;
height: 100vh;
}
</style>
</head>
<body>
<div class="wrap">
<label class="switch">
<input type="checkbox" onclick="change()">
<span class="slider round">
<h1 id="light-text">OFF</h1>
</span>
</label>
</div>
<script type="text/javascript">
function change() {
var x = document.getElementById("light-text");
if (x.innerHTML === "OFF") {
x.innerHTML = "ON";
} else {
x.innerHTML = "OFF";
}
var element = document.body;
element.classList.toggle("lights-on");
}
</script>
</body>
</html>