data-scroll-container
, and place sticky elements inside it.<head>
and JS before </body>
, then initialize it with a script targeting the scroll container.transform
, set top
in CSS, and disable Webflow’s native smooth scroll.To implement smooth scrolling with Locomotive.js in Webflow and keep position: sticky working correctly, you need to properly configure both Locomotive Scroll and your CSS. Here's how to do it:
<div>
wrapper. Commonly, this is called something like #smooth-wrapper
or #js-scroll
.data-scroll-container
. This is required for Locomotive.js to know what element to control.data-scroll-container
</head>
, include the Locomotive Scroll CSS using an Embed:https://cdn.jsdelivr.net/npm/locomotive-scroll@4.1.4/dist/locomotive-scroll.min.css
</body>
, include:https://cdn.jsdelivr.net/npm/locomotive-scroll@4.1.4/dist/locomotive-scroll.min.js
Place this script in a Custom Code Embed just before the closing </body>
:
```
```
Optional: Reinitialize scroll when using Webflow interactions or content loads dynamically.
Example: After finishing Webflow’s IX2
animations, you can re-call scroll.update()
.
position: sticky
Worksposition: sticky
by default.position: sticky
only on elements that are inside the scroll container and not affected by transform
.position: sticky
behaves inside transformed parents.top: 0;
).Page Settings
, scroll to the bottom and disable “Smooth Scroll”. Locomotive handles this already.To use Locomotive.js smooth scrolling with sticky elements in Webflow, wrap content in a data-scroll-container
div, initialize Locomotive Scroll properly, and avoid applying transform
to any parent of sticky elements. Place sticky elements inside the scroll container with top
defined, and ensure Webflow's smooth scroll is disabled.