-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
120 lines (111 loc) · 3.17 KB
/
index.html
File metadata and controls
120 lines (111 loc) · 3.17 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
<!DOCTYPE html>
<html lang="pt-br">
<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>Card Nubank</title>
<link rel="shortcut icon" href="nubank_logo.png" type="image/x-icon">
<style>
body{
background-color: rgb(36,36,36);
font-family: Arial, Helvetica, sans-serif;
color: #fff;
display: flex;
flex-direction: column;
align-items: center;
}
.container{
background-color: #820ad1;
padding: 1em;
border-radius: 10px;
width: 15em;
height: 25em;
box-shadow: 5px 8px 8px #000;
}
img[alt=mastercard]{
width: 30%;
}
img[alt=chip]
{
width: 40%;
transform: rotate(90deg);
}
.footer img{
width: 35%;
}
.content{
display: flex;
flex-direction: column;
height: 100%;
}
.header{
height: 70%;
}
.box-img{
display: flex;
align-items: flex-start;
}
.footer{
height: 30%;
}
.footer p{
margin-left: 1em;
}
</style>
</head>
<body>
<h1>Patricia Silva</h1>
<br>
<div class="container">
<div class="content">
<div class="header">
<div class="box-img">
<img src="mastercard_logo.png" alt="mastercard">
<img src="chip.png" alt="chip">
</div>
</div>
<div class="footer">
<p>Patricia Silva </p>
<img src="nubank_logo.png" alt="nubank">
</div>
</div>
</div>
</body>
<script>
const card = document.querySelector('.container');
card.addEventListener("mousemove", cardEffect);
card.addEventListener("mouseleave", cardBack);
card.addEventListener("mouseenter", cardEnter);
function cardEffect(event)
{
const cardWidth = card.offsetWidth;
const cardHeight = card.offsetHeight;
const centerX = card.offsetLeft + cardWidth/2;
const centerY = card.offsetTop + cardHeight/2;
const positionX = event.clientX - centerX;
const positionY = event.clientY - centerY;
const rotateX = ((+1)*25*positionY/(cardHeight/2)).toFixed(2);
const rotateY = ((-1)*25*positionX/(cardWidth/2)).toFixed(2);
console.log(rotateX,rotateY);
card.style.transform = `perspective(500px) rotateX(${rotateX}deg) rotateY(${rotateY}deg)`;
}
function cardBack(event)
{
card.style.transform = `perspective(500px) rotateX(0deg) rotateY(0deg)`;
cardTransition();
}
function cardTransition()
{
clearInterval(card.transitionId);
card.style.transition = 'transform 400ms';
card.transitionId = setTimeout(() => {
card.style.transition = '';
},400);
}
function cardEnter(event)
{
cardTransition();
}
</script>
</html>