-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParallaxTest.html
180 lines (172 loc) · 4.27 KB
/
ParallaxTest.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!DOCTYPE html>
<html>
<title>Parallax sample</title>
<head>
<style>
body {
margin:0;
padding:0;
position: relative;
}
#firstUL {
position: fixed;
width:100%;
height:50px;
background-color: gray;
z-index: 5;
border-bottom: 1px solid black;
list-style-type: none;
padding: 0;
margin: 0;
-webkit-box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.75);
box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.75);
}
#firstUL > li {
float:left;
text-decoration: none;
display: inline-block;
padding-top:5px;
}
#firstUL > li > a{
font-family: monospace;
font-size: 30px;
padding: 10px 15px 10px 15px;
height:44px;
text-decoration: none;
}
#firstUL > li > a:hover {
background-color:#cecccc;
}
#firstUL > li > a:link, a:visited{
color:black;
}
#photo1 {
position: relative;
top: 50px;
height: 250px;
width: 100%;
}
#climbPic {
width: 100%;
}
#content {
position: relative;;
margin-top: 350px;
height: 1000px;
width: 100%;
background-color: white;
}
h1 {
position: absolute;
left:50px;
top:15px;
}
h2 {
position: absolute;
left:50px;
top:100px;
}
h3 {
position:absolute;
left:50px;
bottom:50px;
}
#dropdownS {
background-color: #cecccc;
width: 200px;
height:87px;
top:10px;
left:-1px;
font-size: 0px;
-webkit-box-shadow: 10px 9px 11px -4px rgba(122,122,122,1);
-moz-box-shadow: 10px 9px 11px -4px rgba(122,122,122,1);
box-shadow: 10px 9px 11px -4px rgba(122,122,122,1);
border: 1px solid black;
position: relative;
display: none;
}
#dropdownS > a {
font-size: 25px;
display:inline-block;
width:180px;
text-decoration: none;
margin:0px;
padding-left: 20px;
font-family: monospace;
}
#dropdownS > a:link, a:visited {
color:black;
}
#dropdownS > a:hover {
background-color: gray;
}
#fadePhoto {
position: absolute;
left:300px;
width: 450px;
height:auto;
top: 500px;
transition: 0.3s;
}
#climbPic2 {
width:100%;
border-radius: 10px;
}
</style>
<script>
function parallax(){ /*Parallax function*/
var x = document.getElementById('photo1');
x.style.top = (window.pageYOffset * .4) +"px"
};
window.addEventListener("scroll", parallax, false);
function dropdown(showHide, x){ /*dropdown menu function*/
var dpdn = document.getElementById(x);
if (showHide === 0) {
dpdn.style.display ="none";
} else {
dpdn.style.display= "block";
}
};
function onscroll(){ /*image appear with scroll*/
var z = document.getElementById('fadePhoto')
var ypos2 = window.pageYOffset
if (ypos2 < 825){
z.style.opacity = "0"
} else {
z.style.opacity = "1"
}
};
window.addEventListener("scroll", onscroll);
</script>
</head>
<body>
<ul id="firstUL">
<li><a href="#">Menu</a></li>
<li onclick="dropdown(1,'dropdownD')" onclick="dropdown(0,'dropdownD')"><a href="#">Sample</a>
<!-- <div id="dropdownD">
<a href="#">onClick<a>
<a href="#">Dropdown<a>
<a href="#">Test<a> -->
</li>
<li onmouseover="dropdown(1,'dropdownS')" onmouseout="dropdown(0,'dropdownS')"><a href="#">Dropdown</a>
<div id="dropdownS">
<a href="#">OnMouseOver<a>
<a href="#">Dropdown<a>
<a href="#">Test<a>
</div>
</li>
</ul>
<div id="photo1">
<img src="http://highpointclimbing.com/downtown/wp-content/themes/highpoint/images/climbing-school/climbing_school_featured.jpg" id="climbPic">
</div>
<div id="content">
<h1>Mouse over "dropdown" to test mouse over feature<h1>
<h2>This is to test scroll parallax</h2>
<div id="fadePhoto">
<img id="climbPic2" src="http://www.communitywealth.com/wp-content/uploads/2012/09/RockClimbing21.jpg">
</div>
<h3>Worked like a charm!</h3>
</div>
</body>
</html>