
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
universal-parallax
Advanced tools
Easy parallax plugin using pure javascript. Also works on mobile platforms. Cross browser support.
Easy parallax plugin using pure javascript. Cross browser support, including mobile platforms. See demo here
$ npm install universal-parallax -S
Include the script in your project.
<script src="node_modules/universal-parallax/dist/universal-parallax.min.js"></script>
Include this CSS file in your project <link href="node_modules/universal-parallax/dist/universal-parallax.min.css" rel="stylesheet">
Or add this CSS
.parallax--container {
position: absolute;
clip: rect(0, auto, auto, 0);
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: -10;
}
.parallax {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
/* optional */
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
If <section> is your container, make the parallax element inside it.
<section>
<div class="parallax" data-parallax-image="path/to/your_image">
</section>
You can also use a class to define your background-image in CSS, instead of using data-parallax-image="".
Fire up the JS function.
new universalParallax().init();
You can change the parallax speed.
// Plugin customization
new universalParallax().init({
speed: 6.0
});
Note: speed: 1.2 is the minimum value before the background image is fixed.
FAQs
Easy parallax plugin using vanilla javascript. Works on mobile devices (really). Lightweight (2kb). Cross browser compatibility
We found that universal-parallax demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.