-
Notifications
You must be signed in to change notification settings - Fork 0
/
card-flip2.php
85 lines (71 loc) · 1.76 KB
/
card-flip2.php
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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Card Flip</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="util.js"></script>
<style>
.container {
width: 200px;
height: 260px;
position: relative;
margin: 0 auto 40px;
border: 1px solid #CCC;
-webkit-perspective: 800px;
}
#card {
width: 100%;
height: 100%;
position: absolute;
-webkit-transition: -webkit-transform 1s;
-webkit-transform-style: preserve-3d;
-webkit-transform-origin: right center;
}
#card figure {
display: block;
height: 100%;
width: 100%;
line-height: 260px;
color: white;
text-align: center;
font-weight: bold;
font-size: 140px;
position: absolute;
-webkit-backface-visibility: hidden;
}
#card .front {
background: red;
}
#card .back {
background: blue;
-webkit-transform: rotateY( 180deg );
}
</style>
<script>
var init = function() {
var card = document.querySelector('#card');
document.querySelector('#show-back').addEventListener( 'click', function(){
card.style.webkitTransform = 'translateX( -100% ) rotateY( -180deg )';
}, false);
document.querySelector('#show-front').addEventListener( 'click', function(){
card.style.webkitTransform = 'translateX( 0% ) rotateY( 0deg )';
}, false);
};
window.addEventListener('DOMContentLoaded', init, false);
</script>
</head>
<body>
<h1>Card Flip 2</h1>
<section class="container">
<div id="card">
<figure class="front">1</figure>
<figure class="back">2</figure>
</div>
</section>
<section id="options">
<p><button id="show-front">Show 1</button></p>
<p><button id="show-back">Show 2</button></p>
</section>
</body>
</html>