-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalcodedemo.html
More file actions
73 lines (69 loc) · 1.92 KB
/
alcodedemo.html
File metadata and controls
73 lines (69 loc) · 1.92 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
<head>
<script>
function docReady(fn) {
// see if DOM is already available
if (document.readyState === "complete" || document.readyState === "interactive") {
// call on next available tick
setTimeout(fn, 1);
} else {
document.addEventListener("DOMContentLoaded", fn);
}
}
let togglestate = false;
docReady(function() {
document.getElementsByClassName('switch-thumb')[0]
.addEventListener('click', function (event) {
if (togglestate){
document.getElementsByClassName("switch-thumb")[0].style.left="1vw";
document.getElementsByClassName("switch")[0].style.background="grey";
togglestate = !togglestate;
//style changes
document.body.style.background="white";
document.getElementsByClassName("text")[0].style.color="black";
} else{
document.getElementsByClassName("switch-thumb")[0].style.left="25vw";
document.getElementsByClassName("switch")[0].style.background="green";
togglestate = !togglestate;
//style changes
document.body.style.background="#2a2f38";
document.getElementsByClassName("text")[0].style.color="white";
}
});
});
</script>
<style>
.switch{
position: relative;
width: 40vw;
height: 16vw;
border-radius:100vw;
padding:0;
background: grey;
transition: background 0.6s ease, width 0.3s ease;
}
.switch-thumb{
position: absolute;
width: 14vw;
height: 14vw;
top: 1vw;
left: 1vw;
background: white;
border-radius:100vw;
transition: left 0.6s ease;
}
body{
width:100vw;
height:100vh;
background:white;
transition:background 1s ease;
}
.text{
color:black;
transition:color 1s ease;
text-align:center;
}
</style>
</head>
<body>
<div class="switch"><div class="switch-thumb"></div></div><div class="text">AlCode Theme</div>
</body>