-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
54 lines (44 loc) · 1.8 KB
/
example.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>parallaxed.js</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="src/parallaxed.js"></script>
<script type="text/javascript">
$(function() {
$body = $('body');
// Generate some divs
for (var i=0; i<200; i++) {
// Random speed
var speed = Math.random() * 1.5;
// Random position and size
var left = parseInt(Math.random() * $('body').width() * 2 + 1);
var top = parseInt(Math.random() * $(window).height() * 10 + 1);
var size = parseInt(Math.random() * (200*speed) + 50);
// Random color
var r = parseInt(Math.random() * 255).toString(16);
var g = parseInt(Math.random() * 255).toString(16);
var b = parseInt(Math.random() * 255).toString(16);
var div = $('<div style="position:absolute">');
div.css('width', size + 'px');
div.css('height', size + 'px');
div.css('left', left + 'px');
div.css('top', top + 'px');
div.css('z-index', parseInt(speed*100));
div.css('background-color', '#' + r + g + b);
div.data('parallaxed-speed', speed);
$body.append(div);
div.parallaxed();
}
})
</script>
<style type="text/css">
body {
background-color: #111;
}
</style>
</head>
<body>
</body>
</html>