forked from alumbo/jquery.parallax-scroll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stars.html
84 lines (82 loc) · 2.19 KB
/
stars.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
84
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jquery.parallax-scroll bonus stars</title>
<style>
body {
height: 2500px;
background: #000;
overflow-x:hidden;
}
.star1 {
position: absolute;
background: #fff;
width: 4px;
height: 4px;
border-radius: 4px;
}
.star2 {
position: absolute;
display: block;
color: #fff;
width: 0px;
height: 0px;
border-right: 10px solid transparent;
border-bottom: 7px solid #fff;
border-left: 10px solid transparent;
transform: rotate(35deg);
-webkit-transform: rotate(35deg);
}
.star2:before {
border-bottom: 8px solid #fff;
border-left: 3px solid transparent;
border-right: 3px solid transparent;
position: absolute;
height: 0;
width: 0;
top: -4.5px;
left: -6.5px;
display: block;
content: '';
transform: rotate(-35deg);
-webkit-transform: rotate(-35deg);
}
.star2:after {
position: absolute;
display: block;
color: #fff;
top: 1px;
left: -10px;
width: 0px;
height: 0px;
border-right: 10px solid transparent;
border-bottom: 7px solid #fff;
border-left: 10px solid transparent;
transform: rotate(-70deg);
-webkit-transform: rotate(-70deg);
content: '';
}
</style>
</head>
<body>
<script src="js/jquery-2.1.3.min.js"></script>
<script src="js/jquery.parallax-scroll.js"></script>
<script>
$(function(){
var windowWidth = $(window).width();
for(var i=0; i<100; i++) {
var top = Math.random()*2200 - 50;
var left = Math.random()*(windowWidth+50) - 50;
var x = Math.random()*2000-1000;
var y = Math.random()*2000-1000;
var z = Math.random()*1500-1000;
var rotateZ = Math.random()*600-300;
var fromScroll = Math.max(0, top - 200 - Math.random()*800);
var distance = 200+Math.random()*100;
$("body").append('<div class="star'+((Math.random()>.5)?'1':'2')+'" style="top:' + top + 'px; left:' + left + 'px;" data-parallax=\'{"x":' + x + ',"y":' + y + ',"z":' + z + ',"rotateZ":' + rotateZ + ',"from-scroll":' + fromScroll + ',"distance":' + distance + '}\'></div>');
}
});
</script>
</body>
</html>