-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitch.seperate.css
49 lines (49 loc) · 1.31 KB
/
switch.seperate.css
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
:root, :host {
--switch: hsl(0, 0%, 73%);
--switch-active: hsl(231, 48%, 48%);
--switch-knob-radius: 10px;
--switch-radius: 7px;
--switch-offset: calc(var(--switch-knob-radius) - var(--switch-radius));
}
.switch__container {
position: relative;
display: block;
width: 36px;
height: calc(2 * var(--switch-knob-radius));
margin: var(--switch-offset) 0;
}
input#switch:focus ~ .switch__container .switch__background {
outline: 1px solid rgb(77, 144, 254);
}
input#switch:checked ~ .switch__container .switch__background{
background: var(--switch-active);
filter: saturate(50%) brightness(150%)
}
input#switch:checked ~ .switch__container .switch__nub {
background: var(--switch-active);
right: 0
}
.switch__container .switch__background {
background-color: var(--switch);
}
.switch__background {
display: block;
width: 36px;
height: calc(2 * var(--switch-radius));
border-radius: var(--switch-radius);
position: absolute;
margin: var(--switch-offset) 0;
}
input#switch {
opacity: 0;
position: absolute;
}
.switch__nub {
width: calc(2 * var(--switch-knob-radius));
height: calc(2 * var(--switch-knob-radius));
position: absolute;
border-radius: 50%;
background: white;
z-index: 1;
box-shadow: 0px 0px 5px rgba(0,0,0,0.2)
}