Webflow sync, pageviews & more.
NEW

How can I create parallax elements in Webflow using the script from the provided link on Matthew Wagerfield's website?

TL;DR
  • Add the Parallax.js script to your Webflow project's head code and publish the site.
  • Create a container with a unique ID in Webflow, add layered child elements with data-depth attributes, and initialize Parallax in the footer using JavaScript targeting the container ID.

To create parallax elements in Webflow using Matthew Wagerfield's Parallax.js, you'll need to integrate the provided JavaScript library properly and set up the elements in Webflow to respond to it.

1. Understand What Parallax.js Does

  • Parallax.js by Matthew Wagerfield allows you to create mouse-based parallax effects on layered elements.
  • It listens to mouse movement and shifts child elements based on depth attributes to simulate depth.

2. Add Parallax.js to Your Webflow Project

  • Go to Project Settings > Custom Code > Head Code.

  • Add this line inside the head tag to include the script:

    <script src="https://cdnjs.cloudflare.com/ajax/libs/parallax/3.1.0/parallax.min.js"></script>

  • Alternatively, if Matthew’s official website provides a direct script URL, you can use that instead.

  • Save changes and publish your project.

3. Set Up the HTML Structure in Webflow

  • Create a parent div (e.g., “parallax-container”) and give it a unique ID (parallax-scene).

  • Add multiple child elements (like images, divs, or SVGs) inside this container. They will move at different speeds.

  • Each child needs a custom attribute:

  • Click on a child element > Settings Tab > Custom Attributes

  • Add: Name: data-depth, Value: a decimal like 0.2, 0.6, or 1.0 (higher = faster movement)

4. Activate the Parallax Script

  • Go to Page Settings > Footer Code (Before tag)

  • Add this custom script:

    <script>var scene = document.getElementById('parallax-scene'); var parallaxInstance = new Parallax(scene);</script>

  • This script activates Parallax.js on the container with ID parallax-scene.

5. Style Elements in Webflow

  • Use absolute or relative positioning on child layers to stack them visually.
  • You can also size them creatively to enhance the layered depth effect.

6. Test the Published Site

  • Parallax effects won’t work in the Webflow Designer.
  • Publish the site, then test on desktop (mouse movement only; not touch/mobile optimized out-of-the-box).

Summary

To use Parallax.js in Webflow, load the script via the project’s head code, structure elements with data-depth attributes inside a scene container, and initialize the effect with a script in the footer. The parallax will work based on mouse movement on the published site.

Rate this answer

Other Webflow Questions