-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
83 lines (67 loc) · 1.65 KB
/
index.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!DOCTYPE html>
<html>
<head>
<title> Aula Parallax </title>
<meta charset="UTF-8">
<style>
body {
margin: 0px;
background: url(imgs/background.jpg) fixed;
width: 100%;
height: auto;
}
h1 { color: transparent; }
#content {
position: absolute;
}
.img-parallax {
position: fixed;
width: 100%;
height: 1000px;
}
#layer_1 {
background: url("imgs/rock_1.png") no-repeat 0px 200px;
}
#layer_2 {
background: url("imgs/owl_1.png") no-repeat 600px 400px;
}
#layer_3 {
background: url("imgs/rock_2.png") no-repeat 700px 10px;
}
#layer_4 {
background: url("imgs/rock_3.png") no-repeat -120px 400px;
}
</style>
<script>
function parallax(){
// Declarando as var.
var layer_1 = document.getElementById('layer_1');
var layer_2 = document.getElementById('layer_2');
var layer_3 = document.getElementById('layer_3');
var layer_4 = document.getElementById('layer_4');
// Aplicando a posição
layer_1.style.top = -(window.pageYOffset / 3) + 'px';
layer_2.style.top = -(window.pageYOffset / 6) + 'px';
layer_3.style.top = -(window.pageYOffset / 7) + 'px';
layer_4.style.top = -(window.pageYOffset / 7) + 'px';
}
window.addEventListener("scroll", parallax, false);
</script>
</head>
<body>
<section>
<div id="layer_3" class="img-parallax"></div>
<div id="layer_4" class="img-parallax"></div>
<div id="layer_1" class="img-parallax"></div>
<div id="layer_2" class="img-parallax"></div>
</section>
<article id="content">
<script>
for(var i=1; i < 50; i++)
{
document.write('<h1>Testando parallax' +i+ '</h1>');
}
</script>
</article>
</body>
</html>