-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path3D_Parralax_Effect.html
62 lines (62 loc) · 1.72 KB
/
3D_Parralax_Effect.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
<!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>Parallax Effects</title>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
user-select: none;
}
section{
user-select: none;
position: relative;
height: 100vh;
overflow: hidden;
}
section #bg{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: url(assets/Parallax/bg.jpg);
background-size: calc(100% + var(--x)/2);
background-position: center;
}
section .girl{
position: absolute;
top: 0;
width: 400px;
left: 50%;
max-width: calc(400px + var(--x)/50);
}
section h2{
position: absolute;
top: 50%;
width: 100%;
color: #fff;
font-size: 8em;
text-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
transform: translate(calc(100% - var(--x)*2),-50%);
}
</style>
</head>
<body>
<section>
<div id="bg"></div>
<h2>3D Parralax Effects</h2>
<img src="assets/Parallax/img.png" class="girl" alt="">
</section>
<script>
var position = document.documentElement;
position.addEventListener("mousemove",e=>{
position.style.setProperty('--x',e.clientX + "px");
})
</script>
</body>
</html>