-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflip.php
More file actions
200 lines (194 loc) · 4.8 KB
/
flip.php
File metadata and controls
200 lines (194 loc) · 4.8 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
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
189
190
191
192
193
194
195
196
197
198
199
200
<section id="flip">
<h1>Flipping content</h1>
<p>Proper flipping requires 3D Transform support - currently only in Safari. You still get the effect in other browsers, but it's not as cool!</p>
<h2>Demo 1 - Flipping a simple image to a div (transitions and 3d transforms)</h2>
<p class="note">As of May 2010, this only works in Webkit and Safari, both desktop and mobile. It doesn't work anywhere else.</p>
<h3>Plan</h3>
<ol>
<li>Put an image on top of a div inside a container.</li>
<li>Put that in another container with perspective defined.</li>
<li>When hovering on the outside container, add a rotate around the Y axis to the inside container.</li>
</ol>
<h3>Demo</h3>
<style>
#f1_container {
position: relative;
margin: 10px auto;
width: 450px;
height: 281px;
z-index: 1;
}
.face.back {
display: none;
}
#f1_container {
-webkit-perspective: 1000;
}
#f1_card {
width: 100%;
height: 100%;
-webkit-transform-style: preserve-3d;
-webkit-transition: all 1.0s linear;
}
#f1_container:hover #f1_card, #f1_container.hover_effect #f1_card {
-webkit-transform: rotateY(180deg);
-webkit-box-shadow: -5px 5px 5px #aaa;
-moz-box-shadow: -5px 5px 5px #aaa;
box-shadow: -5px 5px 5px #aaa;
}
.face {
position: absolute;
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
}
.face.back {
display: block;
-webkit-transform: rotateY(180deg);
-webkit-box-sizing: border-box;
padding: 10px;
color: white;
text-align: center;
background-color: #aaa;
}
</style>
<div id="f1_container" class="hover">
<div id="f1_card" class="shadow">
<div class="front face">
<img src="/images/Stones.jpg"/>
</div>
<div class="back face center">
<p>This is nice for exposing more information about an image.</p>
<p>Any content can go here.</p>
</div>
</div>
</div>
<h3>Code</h3>
<p>First, the markup.</p>
<pre class="html">
<div id="f1_container">
<div id="f1_card" class="shadow">
<div class="front face">
<img src="/images/Stones.jpg"/>
</div>
<div class="back face center">
<p>This is nice for exposing more information about an image.</p>
<p>Any content can go here.</p>
</div>
</div>
</div>
</pre>
<p>Then the CSS</p>
<pre class="css">
#f1_container {
position: relative;
margin: 10px auto;
width: 450px;
height: 281px;
z-index: 1;
}
.face.back {
display: none;
}
#f1_container {
-webkit-perspective: 1000;
}
#f1_card {
width: 100%;
height: 100%;
-webkit-transform-style: preserve-3d;
-webkit-transition: all 1.0s linear;
}
#f1_container:hover #f1_card {
-webkit-transform: rotateY(180deg);
-webkit-box-shadow: -5px 5px 5px #aaa;
-moz-box-shadow: -5px 5px 5px #aaa;
box-shadow: -5px 5px 5px #aaa;
}
.face {
position: absolute;
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
}
.face.back {
display: block;
-webkit-transform: rotateY(180deg);
-webkit-box-sizing: border-box;
padding: 10px;
color: white;
text-align: center;
background-color: #aaa;
}
</pre>
<p>You can also flip around the X and Z axes:</p>
<style>
#f2_container {
position: relative;
margin: 10px auto;
width: 450px;
height: 281px;
z-index: 1;
}
#f2_container {
-webkit-perspective: 1000;
}
#f2_card {
width: 100%;
height: 100%;
-webkit-transform-style: preserve-3d;
-webkit-transition: all 1.0s linear;
}
#f2_container:hover #f2_card, #f2_container.hover_effect #f2_card {
-webkit-transform: rotateX(180deg);
-webkit-box-shadow: 5px -5px 5px #aaa;
-moz-box-shadow: 5px -5px 5px #aaa;
box-shadow: 5px -5px 5px #aaa;
}
</style>
<div id="f2_container" class="hover">
<div id="f2_card" class="shadow">
<div class="front face">
<img src="/images/Cirques.jpg"/>
</div>
<div class="back face center">
<p>Note that I've had to change the shadow to keep it looking normal.</p>
</div>
</div>
</div>
<style>
#f3_container {
position: relative;
margin: 10px auto;
width: 450px;
height: 281px;
z-index: 1;
}
#f3_container {
-webkit-perspective: 1000;
}
#f3_card {
width: 100%;
height: 100%;
-webkit-transform-style: preserve-3d;
-webkit-transition: all 1.0s linear;
}
#f3_container:hover #f3_card, #f3_container.hover_effect #f3_card {
-webkit-transform: rotateZ(180deg);
-webkit-box-shadow: -5px -5px 5px #aaa;
-moz-box-shadow: -5px -5px 5px #aaa;
box-shadow: -5px -5px 5px #aaa;
}
</style>
<div id="f3_container" class="hover">
<div id="f3_card" class="shadow">
<div class="front face">
<img src="/images/Stones.jpg"/>
</div>
<div class="back face center">
<p>This is nice for exposing more information about an image.</p>
<p>Any content can go here.</p>
</div>
</div>
</div>
</section>