Skip to content

A zero-dependency, super-lightweight JavaScript snippet to add a subtle parallax effect to background-images

Notifications You must be signed in to change notification settings

alitorbati/parallaxify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

parallaxify

A zero-dependency, super-lightweight JavaScript snippet to add a subtle parallax effect to background-images

Demo

Usage

HTML

<script src="parallaxify.js"></script>

JavaScript

document.addEventListener("DOMContentLoaded", (event) => {
  parallaxify(".some-class");
});

CSS

.some-class {
  height: 130px; /* any value smaller than the image height */
  background-image: url("some-image.jpg");
  background-size: cover;
  background-position-x: 50%;
  background-position-y: 0%;
  background-repeat: no-repeat;
}

About

A zero-dependency, super-lightweight JavaScript snippet to add a subtle parallax effect to background-images

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published