-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparallax.html
More file actions
43 lines (40 loc) · 804 Bytes
/
parallax.html
File metadata and controls
43 lines (40 loc) · 804 Bytes
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
<style>
body {
margin: 0;
background: #e6e6e6;
}
header {
position: fixed;
top: 0;
width: 100%;
z-index: -1;
height: 500px;
line-height: 500px;
text-align: center;
margin: 0; padding: 0;
}
.wrapper-parallax {
margin-top: 500px;
}
.content {
position: relative;
z-index: 1;
background: white;
min-height: 1800px;
}
</style>
<div class="wrapper-parallax">
<header>
<h1 class="logo">Header</h1>
</header>
<div class="content">
<h1>Content</h1>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(window).scroll(function(){
var fromTop = $(window).scrollTop();
$(".logo").css('margin', '-' + (100 - fromTop) + 'px 0px 0px 0px');
});
</script>