Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
·
9496819
1
Parent(s):
ad35937
refactor: 优化开关样式,重写亮暗色切换开关样式
Browse files- assets/custom.css +51 -21
- assets/html/appearance_switcher.html +5 -10
assets/custom.css
CHANGED
@@ -201,14 +201,42 @@ footer {
|
|
201 |
line-height: 20px;
|
202 |
}
|
203 |
|
204 |
-
/*
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
top: 2px;
|
207 |
display: inline-block;
|
208 |
-
height:
|
209 |
position: relative;
|
210 |
-
width:
|
211 |
-
border-radius:
|
|
|
212 |
}
|
213 |
.apSwitch input {
|
214 |
display: none !important;
|
@@ -222,12 +250,11 @@ footer {
|
|
222 |
right: 0;
|
223 |
top: 0;
|
224 |
transition: .4s;
|
225 |
-
font-size:
|
226 |
-
border-radius:
|
227 |
}
|
228 |
.apSlider::before {
|
229 |
-
|
230 |
-
left: 1px;
|
231 |
position: absolute;
|
232 |
transition: .4s;
|
233 |
content: "🌞";
|
@@ -236,9 +263,9 @@ input:checked + .apSlider {
|
|
236 |
background-color: var(--primary-600);
|
237 |
}
|
238 |
input:checked + .apSlider::before {
|
239 |
-
transform: translateX(
|
240 |
content:"🌚";
|
241 |
-
}
|
242 |
|
243 |
.switch_checkbox label {
|
244 |
flex-direction: row-reverse;
|
@@ -260,10 +287,11 @@ input:checked + .apSlider::before {
|
|
260 |
position: relative !important;
|
261 |
border: none !important;
|
262 |
outline: none;
|
263 |
-
width:
|
264 |
-
height:
|
265 |
-
border-radius:
|
266 |
-
|
|
|
267 |
background-image: none !important;
|
268 |
background-color: var(--switch-checkbox-color-light) !important;
|
269 |
transition: .2s ease background-color;
|
@@ -274,13 +302,15 @@ input:checked + .apSlider::before {
|
|
274 |
.switch_checkbox input[type="checkbox"]::before {
|
275 |
content: "";
|
276 |
position: absolute;
|
277 |
-
width:
|
278 |
-
height:
|
279 |
top: 0;
|
280 |
left: 0;
|
281 |
-
background
|
282 |
-
|
283 |
-
|
|
|
|
|
284 |
transition: .4s ease all;
|
285 |
box-shadow: var(--input-shadow);
|
286 |
}
|
@@ -289,7 +319,7 @@ input:checked + .apSlider::before {
|
|
289 |
}
|
290 |
.switch_checkbox input:checked[type="checkbox"]::before {
|
291 |
background-color: #fff;
|
292 |
-
left:
|
293 |
}
|
294 |
|
295 |
/* Override Slider Styles (for webkit browsers like Safari and Chrome)
|
|
|
201 |
line-height: 20px;
|
202 |
}
|
203 |
|
204 |
+
/* 亮暗色模式切换 */
|
205 |
+
#apSwitch input[type="checkbox"] {
|
206 |
+
margin: 0 !important;
|
207 |
+
}
|
208 |
+
#apSwitch label.apSwitch {
|
209 |
+
display: flex;
|
210 |
+
align-items: center;
|
211 |
+
cursor: pointer;
|
212 |
+
color: var(--body-text-color);
|
213 |
+
font-weight: var(--checkbox-label-text-weight);
|
214 |
+
font-size: var(--checkbox-label-text-size);
|
215 |
+
line-height: var(--line-md);
|
216 |
+
margin: 2px 0 !important;
|
217 |
+
}
|
218 |
+
input[type="checkbox"]#apSwitch_checkbox::before {
|
219 |
+
background: none !important;
|
220 |
+
content: '🌞';
|
221 |
+
border: none !important;
|
222 |
+
box-shadow: none !important;
|
223 |
+
font-size: 22px;
|
224 |
+
top: -4.4px;
|
225 |
+
left: -1px;
|
226 |
+
}
|
227 |
+
input:checked[type="checkbox"]#apSwitch_checkbox::before {
|
228 |
+
content: '🌚';
|
229 |
+
left: 16px;
|
230 |
+
}
|
231 |
+
|
232 |
+
/* .apSwitch {
|
233 |
top: 2px;
|
234 |
display: inline-block;
|
235 |
+
height: 22px;
|
236 |
position: relative;
|
237 |
+
width: 40px;
|
238 |
+
border-radius: 11px;
|
239 |
+
box-shadow: inset 0 0 1px 0 rgba(0,0,0,0.05), inset 0 0 2px 0 rgba(0,0,0,0.08) !important;
|
240 |
}
|
241 |
.apSwitch input {
|
242 |
display: none !important;
|
|
|
250 |
right: 0;
|
251 |
top: 0;
|
252 |
transition: .4s;
|
253 |
+
font-size: 22px;
|
254 |
+
border-radius: 11px;
|
255 |
}
|
256 |
.apSlider::before {
|
257 |
+
transform: scale(0.9);
|
|
|
258 |
position: absolute;
|
259 |
transition: .4s;
|
260 |
content: "🌞";
|
|
|
263 |
background-color: var(--primary-600);
|
264 |
}
|
265 |
input:checked + .apSlider::before {
|
266 |
+
transform: translateX(18px);
|
267 |
content:"🌚";
|
268 |
+
} */
|
269 |
|
270 |
.switch_checkbox label {
|
271 |
flex-direction: row-reverse;
|
|
|
287 |
position: relative !important;
|
288 |
border: none !important;
|
289 |
outline: none;
|
290 |
+
width: 40px !important;
|
291 |
+
height: 22px !important;
|
292 |
+
border-radius: 11px !important;
|
293 |
+
background-image: none !important;
|
294 |
+
box-shadow: inset 0 0 1px 0 rgba(0,0,0,0.05), inset 0 0 2px 0 rgba(0,0,0,0.08) !important;
|
295 |
background-image: none !important;
|
296 |
background-color: var(--switch-checkbox-color-light) !important;
|
297 |
transition: .2s ease background-color;
|
|
|
302 |
.switch_checkbox input[type="checkbox"]::before {
|
303 |
content: "";
|
304 |
position: absolute;
|
305 |
+
width: 22px;
|
306 |
+
height: 22px;
|
307 |
top: 0;
|
308 |
left: 0;
|
309 |
+
background: #FFFFFF;
|
310 |
+
border: 0.5px solid rgba(0,0,0,0.02);
|
311 |
+
box-shadow: 0 0 0 0 rgba(0,0,0,0.15), 0 1px 0 0 rgba(0,0,0,0.05);
|
312 |
+
transform: scale(0.9);
|
313 |
+
border-radius: 11px !important;
|
314 |
transition: .4s ease all;
|
315 |
box-shadow: var(--input-shadow);
|
316 |
}
|
|
|
319 |
}
|
320 |
.switch_checkbox input:checked[type="checkbox"]::before {
|
321 |
background-color: #fff;
|
322 |
+
left: 18px;
|
323 |
}
|
324 |
|
325 |
/* Override Slider Styles (for webkit browsers like Safari and Chrome)
|
assets/html/appearance_switcher.html
CHANGED
@@ -1,11 +1,6 @@
|
|
1 |
-
<div
|
2 |
-
<
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
<label class="apSwitch" for="checkbox">
|
7 |
-
<input type="checkbox" id="checkbox">
|
8 |
-
<div class="apSlider"></div>
|
9 |
-
</label>
|
10 |
-
</span>
|
11 |
</div>
|
|
|
1 |
+
<div class="switch_checkbox" id="apSwitch">
|
2 |
+
<label class="apSwitch">
|
3 |
+
<input type="checkbox" id="apSwitch_checkbox" data-testid="checkbox" />
|
4 |
+
<span class="apSwitch_span">{label}</span>
|
5 |
+
</label>
|
|
|
|
|
|
|
|
|
|
|
6 |
</div>
|