Skip to main content
Jarallax provides multiple ways to create parallax scrolling effects. This guide covers the fundamentals of setting up image parallax effects.

Installation

First, install Jarallax in your project:

Import Methods

Choose the import method that best fits your project setup.

Using the jarallax-img Class

The most flexible way to add parallax images is using the jarallax-img class on an <img> element.
1

Add HTML Structure

Create a container with the jarallax class and an image with the jarallax-img class:
The jarallax-img class is the default selector (defined in imgElement option). You can customize this selector if needed.
2

Initialize Jarallax

Initialize Jarallax on your elements:
3

Add Custom Styles

Style your parallax container as needed:
Using <img> tags with the jarallax-img class allows better SEO and accessibility compared to CSS background images.

Using Picture Elements

For responsive images with different sources, use the <picture> element:

Background Image Method

You can also use CSS background images for simpler setups:
When using CSS background images, the image won’t be visible to screen readers or search engines. Use the jarallax-img class method for better accessibility.

Data Attribute Initialization

In UMD mode, Jarallax supports automatic initialization via data attributes:
The data-jarallax attribute triggers automatic initialization. All options can be set as data attributes using the data- prefix (e.g., data-speed, data-img-src, data-type).

Common Configuration Options

Controls the parallax effect speed. Accepts values from -1.0 to 2.0.
  • 0.5 (default): Standard parallax effect
  • 1.0: No parallax (moves with scroll)
  • 0: Background is fixed
  • Negative values: Parallax in reverse direction
Sets the image position using CSS background-position or object-position values.
Examples: 'top center', '20% 80%', 'left bottom'
Sets the image size using CSS background-size or object-fit values.
Options: 'cover', 'contain', 'auto', '100% 100%'
Controls image repetition (for background images only).
Options: 'no-repeat', 'repeat', 'repeat-x', 'repeat-y'
Keep the <img> tag in its default place after initialization.
When true, Jarallax clones the image instead of moving it.
Sets the z-index of the parallax container.

Complete Example

Here’s a complete working example:

jQuery No Conflict

If you’re using jQuery and need to prevent namespace collisions:

Next Steps

Video Backgrounds

Learn how to use YouTube, Vimeo, and self-hosted videos

Advanced Options

Explore different parallax types and mobile optimization