Jarallax provides multiple ways to create parallax scrolling effects. This guide covers the fundamentals of setting up image parallax effects.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nk-o/jarallax/llms.txt
Use this file to discover all available pages before exploring further.
Installation
First, install Jarallax in your project:Import Methods
Choose the import method that best fits your project setup.- ES Modules (Bundlers)
- ESM CDN
- UMD (Browser)
- jQuery
Using the jarallax-img Class
The most flexible way to add parallax images is using thejarallax-img class on an <img> element.
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.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:- Inline Style
- imgSrc Option
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
speed
speed
Controls the parallax effect speed. Accepts values from
-1.0 to 2.0.0.5(default): Standard parallax effect1.0: No parallax (moves with scroll)0: Background is fixed- Negative values: Parallax in reverse direction
imgPosition
imgPosition
Sets the image position using CSS background-position or object-position values.Examples:
'top center', '20% 80%', 'left bottom'imgSize
imgSize
Sets the image size using CSS background-size or object-fit values.Options:
'cover', 'contain', 'auto', '100% 100%'imgRepeat
imgRepeat
Controls image repetition (for background images only).Options:
'no-repeat', 'repeat', 'repeat-x', 'repeat-y'keepImg
keepImg
Keep the When
<img> tag in its default place after initialization.true, Jarallax clones the image instead of moving it.zIndex
zIndex
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
