-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlightDark.html
More file actions
128 lines (107 loc) · 3.2 KB
/
lightDark.html
File metadata and controls
128 lines (107 loc) · 3.2 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Switch Light-Dark</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,300;0,500;0,700;1,100;1,300&display=swap" rel="stylesheet">
</head>
<body>
<!-- Javascript -->
<script>
const mode = document.querySelector('#night');
const body = document.querySelector('body');
mode.addEventListener('change', () => {
body.classList.toggle('nightmode')
})
</script>
<!-- Estilos -->
<style>
.switch {
position: relative;
}
body {
font-family: Montserrat;
transition: .4s all ease-in;
background: #d8b3a3;
display: flex;
justify-content: center;
align-items: center;
}
body:has(input[type="checkbox"]:checked) {
transition: .4s all ease-in;
background: #252525;
color:#d1d5da;
}
input[type="checkbox"] {
width: 90px;
height: 50px;
background: transparent;
-webkit-appearance: none;
outline: none;
border-radius: 99999px;
border: 5px solid #d1d5da;
}
input[type="checkbox"]:checked {
transition: .4s all ease-in;
border-color: #3a1d6d;
background: #271052;
}
input[type="checkbox"]::before {
content: '\f186';
font-family: 'Arial';
font-weight: 900;
font-size: 25px;
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 2px;
left: 0;
width: 50px;
height: 50px;
background: #2f363d;
border-radius: 50%;
transform: scale(-1.05) rotate(60deg);
color: #ffdf5d;
transition: all .4s linear;
}
input[type="checkbox"]:checked::before {
left: 50px;
background: #6e40c9;
}
.boxes{
max-width: 600px;
width:100%;
color:#252525;
border-radius: 30px;
border: 3px solid #252525;
background-color: #d1d5da;
padding: 20px;
}
p:has(input[type="checkbox"]:checked){
color:#d1d5d1;
}
h1{
text-align: center;
}
</style>
<!-- Estructura -->
<div class="messages">
<div class="switch">
<input type="checkbox" id="night">
</div>
<div class="chat">
<h1> Light-Dark Mode</h1>
<div class="boxes">
<h2>Apretá el switch</h2>
<span></span><br>
<p>Y probá cuál estilo te gusta más</p>
</div>
</div>
</div>
</body>
</html>