-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha.html
More file actions
55 lines (50 loc) · 1.45 KB
/
a.html
File metadata and controls
55 lines (50 loc) · 1.45 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
<!DOCTYPE html>
<html>
<head>
<style>
body {
display: flex;
height: 100vh;
align-items: center;
justify-content: center;
background: #f0f0f0;
margin: 0;
}
.card {
width: 300px;
height: 400px;
background: linear-gradient(135deg, #89f7fe, #66a6ff);
border-radius: 16px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
transition: transform 0.1s ease-out;
transform-style: preserve-3d;
perspective: 1000px;
}
</style>
</head>
<body>
<div class="card">
<h1>Hover Me</h1>
<p>3D Pivot Effect</p>
</div>
<script>
const card = document.querySelector(".card");
card.addEventListener("mousemove", (e) => {
const { width, height, left, top } = card.getBoundingClientRect();
const x = e.clientX - (left + width / 2);
const y = e.clientY - (top + height / 2);
const rotateX = ((-1 * y) / (height / 2)) * 10; // max ±10°
const rotateY = (x / (width / 2)) * 10;
card.style.transform = `perspective(1000px) rotateX(${rotateX}deg) rotateY(${rotateY}deg)`;
});
card.addEventListener("mouseleave", () => {
card.style.transform =
"perspective(1000px) rotateX(0deg) rotateY(0deg)";
});
</script>
</body>
</html>