_form.css
2.39 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
.checkbox,
.radio {
position: relative;
display: inline-block;
label {
padding-left: 33px;
&:before {
z-index: 8;
border: 2px solid $black;
content: "";
}
&:after {
position: absolute;
top: 6px;
left: 12px;
z-index: 9;
display: none;
content: "";
width: 8px;
height: 16px;
transform: rotate(45deg);
border: 2px solid $white;
border-top: 0;
border-left: 0;
}
}
label:before,
input {
position: absolute;
top: 0;
left: 0;
width: 30px;
height: 30px;
}
input {
z-index: 10;
opacity: 0;
}
/* when checked */
input:checked {
~ label:before {
background: $black;
}
~ label:after {
display: block;
}
}
/* when disabled */
input:disabled {
~ label {
color: #ccc;
}
~ label:before {
border-color: #e4e4e4;
}
&:checked {
~ label:before {
background-color: #e4e4e4;
}
}
}
}
.radio {
label:before {
border-radius: 50%;
}
}
.switch {
display: inline-block;
input {
display: none;
&:checked ~ label {
border: 2px solid #4bd865;
box-shadow: inset 0 0 0 calc(19px) #4bd865;
}
&:checked ~ label:after {
left: calc(54px - 34px);
box-shadow: 0 5px 5px -1px rgba(0, 0, 0, 0.2), 0 0 0 2px #4bd865;
}
&:disabled ~ label {
opacity: 0.6;
}
&:disabled:checked ~ label {
opacity: 0.6;
}
}
label {
position: relative;
display: inline-block;
width: 54px;
height: 34px;
background-color: $white;
border: 2px solid #ddd;
border-radius: 99999px;
transition: 0.3s;
&:after {
content: "";
position: absolute;
left: 0;
width: 30px;
height: 30px;
border: none;
border-radius: 50%;
background-color: $white;
box-shadow: 0 5px 5px -1px rgba(0, 0, 0, 0.2), 0 0 0 2px #ddd;
transition: 0.3s;
}
}
}