-
Notifications
You must be signed in to change notification settings - Fork 0
/
flipimage.html
105 lines (103 loc) · 2.95 KB
/
flipimage.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
<!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">
<title>Flip Image</title>
<style>
*{padding: 0;margin: 0;}
body{display: flex;justify-content: center;align-items: center;min-height: 100vh;}
.imgBox {
width: 400px;
height: 400px;
background: #000;
transform-style: preserve-3d;
perspective: 1000px;
}
.imgBox input[type='checkbox'] {
position: relative;
width: 400px;
height: 400px;
appearance: none;
-webkit-appearance: none;
outline: none;
cursor: pointer;
}
span {
position: absolute;
width: 50%;
height: 100%;
pointer-events: none;
transform-style: preserve-3d;
top: 0;
}
span.bg1 {
left: 0;
background: url(images/img1.png);
}
span.bg1::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: url(images/img2.png);
transform-origin: right;
transition: 2s;
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
}
.imgBox input[type='checkbox']:checked ~ span.bg1::before {
transform: rotateY(180deg);
}
span.bg2 {
right: 0;
background: url(images/img2.png);
background-position-x: 200px;
}
span.bg2::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: url(images/img1.png);
background-position-x: 200px;
transform-origin: left;
transition: 2s;
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
transform: rotateY(180deg);
}
.imgBox input[type='checkbox']:checked ~ span.bg2::before {
transform: rotateY(360deg);
}
.bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
transition: 1s;
box-shadow: 0 25px 35px rgba(0, 0, 0, 0.1),
0 0 0 800px #ffa011;
pointer-events: none;
}
.imgBox input[type='checkbox']:checked ~ .bg{
box-shadow: 0 25px 35px rgba(0, 0, 0, .1),
0 0 0 800px #a0d621;
}
</style>
</head>
<body>
<div class="imgBox">
<input type="checkbox">
<span class="bg1"></span>
<span class="bg2"></span>
<div class="bg"></div>
</div>
</body>
</html>