-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdark-mode.css
More file actions
78 lines (67 loc) · 1.67 KB
/
Copy pathdark-mode.css
File metadata and controls
78 lines (67 loc) · 1.67 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
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
:root {
--bg-color: #fff;
--text-color: #121212;
--trans-time: 0.4s;
}
* {
font-family: "Poppins", sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: var(--text-color);
background-color: var(--bg-color);
transition: background-color var(--trans-time) ease-in-out, color var(--trans-time) ease-in-out;
min-height: 100vh;
}
main {
width: 500px;
text-align: center;
}
div {
display: flex;
justify-content: space-evenly;
align-items: center;
width: 100%;
}
/* Moving the checkbox out of the page */
input[type="checkbox"]#dark-mode {
position: absolute;
left: -9000px;
top: -9000px;
}
input[type="checkbox"]#dark-mode + label {
position: relative;
display: flex;
align-items: center;
cursor: pointer;
}
input[type="checkbox"]#dark-mode + label::before {
content: "";
width: 50px;
height: 10px;
background-color: #ddd;
border-radius: 20px;
}
input[type="checkbox"]#dark-mode + label::after {
position: absolute;
left: 0;
content: "";
width: 20px;
height: 20px;
background-color: var(--text-color);
border-radius: 50%;
transition: left var(--trans-time) ease-in-out, background-color var(--trans-time) ease-in-out;
}
input[type="checkbox"]#dark-mode:checked + label::after {
left: calc(50px - 20px); /* 50px is the width of the label */
/* 20px is width of slider */
/* transform: translateX(30px); */ /* This does the same thing */
background-color: var(--text-color);
}