-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathv_1_scrolled_video.html
60 lines (52 loc) · 2.36 KB
/
v_1_scrolled_video.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<title>Scrolled Video 01: with section over it</title>
<meta charset="utf-8">
<style>
/* * {
padding: 0;
margin: 0;
} */
video {
position: fixed;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -1;
top: -20vh;
}
</style>
</head>
<body>
<div class="container-fluid">
<!-- <video id="video" src="assets/obama2.mp4"></video> -->
<video id="video" src="https://web.cw.com.tw/climate-2020/landing/cover-mobile.mp4"></video>
<div style="position:absolute; color:white; z-index:20; width:100%;">
<div style="width:100%; min-height:1000px; background-color: rgba(0, 0, 0, 0.7)"><h1>Section 1</h1></div>
<div style="width:100%; min-height:1000px; background-color: rgba(0, 0, 0, 0.6)"><h1>Section 2</h1></div>
<div style="width:100%; min-height:1000px; background-color: rgba(0, 0, 0, 0.5)"><h1>Section 3</h1></div>
<div style="width:100%; min-height:1000px; background-color: rgba(0, 0, 0, 0.4)"><h1>Section 4</h1></div>
<div style="width:100%; min-height:1000px; background-color: rgba(0, 0, 0, 0.3)"><h1>Section 5</h1></div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>
<script>
$(function() {
var max_scroll = $(document).height() - $(window).height();
$(window).scroll(function(e) {
var video = $('#video').get(0),
videoLength = video.duration,
scrolled = $(document).scrollTop();
video.currentTime = videoLength * (scrolled / max_scroll);
});
});
</script>
</body>
</html>