-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path8_1_parallax_animate.html
64 lines (52 loc) · 2.83 KB
/
8_1_parallax_animate.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
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<style>
img {
width: 10%;
position: absolute;
}
</style>
<title>8_1_parallax_with_animate</title>
</head>
<body>
<div class="container-fluid" style="background-color:beige;min-height: 1000px">
<img id="b1" src="images/ballon01.png" style="left:15%;top:300px">
<img id="b2" src="images/ballon02.png" style="left:25%;top:350px;">
<img id="b3" src="images/ballon03.png" style="left:35%;top:400px;">
<img id="b4" src="images/ballon04.png" style="left:45%;top:450px;">
<img id="b5" src="images/ballon05.png" style="left:55%;top:500px;">
<img id="b6" src="images/ballon06.png" style="left:65%;top:550px;">
</div>
<div class="container-fluid" style="background-color:darkgrey;min-height: 2000px"></div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script>
$(document).ready(function() {
$(window).scroll(function() {
var winh = $(window).height();
var winw = $(window).width();
var scrolled = $(window).scrollTop();
$("#b1").css('top', (300 + scrolled * 1) + 'px');
$("#b2").css('top', (350 + scrolled * .9) + 'px');
$("#b3").css('top', (400 + scrolled * .8) + 'px');
// $("#b4").css('top', (450 + scrolled * .7) + 'px');
$("#b4").css('transition:top', (450 + scrolled * .7) + 'px');
// $("#b5").css('top', (500 + scrolled * .6) + 'px');
$("#b5").css('transform', "translateY(" + (500 + scrolled * .6) + 'px)');
// $("#b6").css('top', (550 + scrolled * .5) + 'px');
$("#b6").animate({top: (550 + scrolled * .5) + 'px'});
});
});
</script>
</body>
</html>