forked from meyer-archives/css-toggle-switch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckbox.css
188 lines (152 loc) · 3.45 KB
/
checkbox.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/* @override http://localhost:8080/checkbox.css */
/* @group Switch */
*{
box-sizing: border-box;
-webkit-user-select: inherit;
}
/* Basic switch dimensions */
.checkbox-switch{
display: block;
height: 24px;
width: 60px;
position: relative;
padding: 1px;
overflow: hidden;
cursor: pointer;
-webkit-user-select: none;
}
/* @group Toggling bit */
.checkbox-switch div{
width: 24px;
height: 22px;
border-radius: 5px;
position: relative;
background-color: #FFF;
/* TODO: Make the background of the switch a grey --> green gradient, transition it as well */
background-image: linear-gradient(
to bottom,
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0.06) 100%);
-webkit-transition-property: -webkit-transform;
-webkit-transition-duration: 240ms;
-webkit-transition-delay: 0;
-webkit-transition-timing-function: cubic-bezier(0.770, 0.000, 0.175, 1.000);
box-shadow:
0 1px 1px rgba(0, 0, 0, 0.2),
0 0 0 1px rgba(0, 0, 0, 0.05);
}
.checkbox-switch input:checked + div{
-webkit-transform: translate3d(34px,0,0);
}
/* @end */
/* @group Track */
/* KILL IT WITH FIRE */
.checkbox-switch,
.checkbox-switch input,
.checkbox-switch:active,
.checkbox-switch input:active
{
-webkit-appearance: none;
-webkit-touch-callout:none;
-webkit-tap-highlight-color:rgba(0,0,0,0);
}
.checkbox-switch input{
margin: 0;
padding: 0;
border: none;
outline: none;
-webkit-appearance: none;
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
height: 100%;
width: 100%;
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0) 100%) #eaeaea;
-webkit-border-radius: 6px;
-webkit-transition: background-color 240ms ease-in-out;
box-shadow:
inset 0 1px 1px rgba(0, 0, 0, 0.2),
inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.checkbox-switch input:checked{
background-color: #a9d88c;
}
/* @end */
/* @group Labels */
.checkbox-switch div:before,
.checkbox-switch div:after{
content: "off";
width: 26px;
height: 24px;
position: absolute;
top: -1px;
left: 100%;
font-weight: 700;
font-size: 10px;
line-height: 24px;
font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
text-transform: uppercase;
padding: 0 6px;
letter-spacing: 0px;
text-shadow: 0 1px 1px rgb(255, 255, 255);
color: #AAA;
-webkit-user-select: none;
-webkit-transform: translate3d(0,0,0);
}
.checkbox-switch div:before{
content: "on";
text-align: right;
left: auto;
right: 100%;
padding-right: 7px;
color: #FFF;
text-shadow: 0 1px 1px rgba(0,0,0,.3);
}
/* @end */
/* @group Click animation */
.checkbox-switch input:active + div,
.checkbox-switch div:active{
/* TODO: get this right */
-webkit-transition-delay: 100ms;
-webkit-transform: translate3d(3px,0,0);
}
.checkbox-switch input:checked:active + div,
.checkbox-switch input:checked + div:active{
-webkit-transform: translate3d(31px,0,0);
}
/* @end */
/* @end */
/* @group Extra */
body,html{
background: #EEE;
margin: 0;
-webkit-text-size-adjust: 100%;
}
.checkbox-container{
background: #FFF;
border-radius: 6px;
/* Here's a gross center-in-page hack */
width: 100px;
height: 64px;
margin: auto;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
box-shadow:
0 1px 1px rgba(0, 0, 0, 0.1),
0 0 0 1px rgba(0, 0, 0, 0.03);
}
.checkbox-switch{
/* More of that voodoo magic */
margin: auto;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
/* @end */