-
Notifications
You must be signed in to change notification settings - Fork 80
/
3D_Flip_Checkbox.html
121 lines (108 loc) · 2.43 KB
/
3D_Flip_Checkbox.html
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
<!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">
<link rel="stylesheet" href="style.css">
<link rel="icon" type="image/png" sizes="32x32" href="logo.png" />
<title>3D Flip Checkbox</title>
</head>
<body>
<div class="center">
<input type="checkbox" name="">
<span>On</span>
<span>Off</span>
</div>
<style>
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
.center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
transform: preserve-3d;
perspective: 200px;
border: 2px solid #000;
height: 40px;
border-radius: 40px;
}
input[type="checkbox"] {
position: relative;
width: 100px;
height: 40px;
margin: 0;
-webkit-appearance: none;
outline: none;
transition: 0.5s;
cursor: pointer;
}
span {
position: absolute;
top: 0;
left: 0;
width: 50%;
height: 100%;
line-height: 40px;
height: 40px;
text-align: center;
text-transform: uppercase;
font-weight: bold;
pointer-events: none;
color: #fff;
transform-style: preserve-3d;
}
span:nth-child(2) {
left: 0;
border-top-left-radius: 40px;
border-bottom-left-radius: 40px;
background: #0f0;
}
span:nth-child(2)::before {
content: '';
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100%;
background: linear-gradient(90deg, #f00, #de0808);
border-top-left-radius: 40px;
border-bottom-left-radius: 40px;
transform-origin: right;
transition: 1s;
backface-visibility: hidden;
}
input[type="checkbox"]:checked~span:nth-child(2)::before {
transform: rotateY(180deg);
}
span:nth-child(3) {
left: 50%;
border-top-right-radius: 40px;
border-bottom-right-radius: 40px;
background: #f00;
}
span:nth-child(3)::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(90deg, #0cd20c, #0f0);
border-top-right-radius: 40px;
border-bottom-right-radius: 40px;
transform-origin: left;
transition: 1s;
backface-visibility: hidden;
transform: rotateY(180deg);
}
input[type="checkbox"]:checked~span:nth-child(3)::before {
transform: rotateY(360deg);
}
</style>
</body>
</html>