.Zip: Example1
.Zip: Example1
Download Example1.zip
Unzip the files and then open index.html in any of your preferred browser.
Each layer is given a fixed position and an assigned z-index in order for the foreground layer to
appear above the background.
Z-index property as you’ve might already known is the one responsible for specifying the stack
order of elements in an HTML document.
Note: Higher stack order is always in front of an element with lower stack order. Please take note
also that z-index property only works on positioned elements (absolute, relative or fixed)
Elements inside each layer have to be absolutely positioned. Make sure that you position elements
in such a way that they align in a pleasing manner when visitors scroll through the site.
4. Next step is jQuery coding.
To achieve a parallax effect, you need to code using jQuery.
Copy the codes shown on the right inside JavaScript external file.
Inside the methodparallaxScroll(), variablescrolled gets the current vertical scrollbar position. This
value then is used to set the CSS top property of each later.
The foreground layer (parallax-bg3) is always aligned to the top of the window or document, while
the speed or movement of the background and midground layers are adjusted according to their
depth.
It’s actually up to you to set the movement of the other layers but as much as possible,
layer parallax-bg1 or the layer who has the lowest stack order moves only a little to achieve the
illusion of depth.
6. Save
your file and check your parallax website.
Now try doing the performance test on your own.