
Documentation
Webflow
Code
Setup: External Scripts
External Scripts in Webflow
Make sure to always put the External Scripts before the Javascript step of the resource.
In this video you learn where to put these in your Webflow project? Or how to include a paid GSAP Club plugin in your project?
HTML
Step 1: Copy structure to Webflow
Copy structure to Webflow
In the video below we described how you can copy + paste the structure of this resource to your Webflow project.
Copy to Webflow
Webflow structure is not required for this resource.
Step 1: Add HTML
HTML
<div data-css-marquee="" class="marquee-css">
<div data-css-marquee-list="" class="marquee-css__list">
<div class="marquee-css__item">
<p class="marquee-css__item-p">CSS Marquee</p>
<svg xmlns="http://www.w3.org/2000/svg" width="100%" viewbox="0 0 50 50" fill="none" class="marquee-css__item-svg"><path d="M17.6777 32.3223C12.9893 27.6339 6.63041 25 0 25C6.63041 25 12.9893 22.3661 17.6777 17.6777C22.3661 12.9893 25 6.63041 25 0C25 6.63041 27.6339 12.9893 32.3223 17.6777C37.0107 22.3661 43.3696 25 50 25C43.3696 25 37.0107 27.6339 32.3223 32.3223C27.6339 37.0107 25 43.3696 25 50C25 43.3696 22.3661 37.0107 17.6777 32.3223Z" fill="#C9FC7D"></path></svg>
</div>
<div class="marquee-css__item">
<p class="marquee-css__item-p">CSS Marquee</p>
<svg xmlns="http://www.w3.org/2000/svg" width="100%" viewbox="0 0 50 50" fill="none" class="marquee-css__item-svg"><path d="M17.6777 32.3223C12.9893 27.6339 6.63041 25 0 25C6.63041 25 12.9893 22.3661 17.6777 17.6777C22.3661 12.9893 25 6.63041 25 0C25 6.63041 27.6339 12.9893 32.3223 17.6777C37.0107 22.3661 43.3696 25 50 25C43.3696 25 37.0107 27.6339 32.3223 32.3223C27.6339 37.0107 25 43.3696 25 50C25 43.3696 22.3661 37.0107 17.6777 32.3223Z" fill="#C9FC7D"></path></svg>
</div>
<div class="marquee-css__item">
<p class="marquee-css__item-p">CSS Marquee</p>
<svg xmlns="http://www.w3.org/2000/svg" width="100%" viewbox="0 0 50 50" fill="none" class="marquee-css__item-svg"><path d="M17.6777 32.3223C12.9893 27.6339 6.63041 25 0 25C6.63041 25 12.9893 22.3661 17.6777 17.6777C22.3661 12.9893 25 6.63041 25 0C25 6.63041 27.6339 12.9893 32.3223 17.6777C37.0107 22.3661 43.3696 25 50 25C43.3696 25 37.0107 27.6339 32.3223 32.3223C27.6339 37.0107 25 43.3696 25 50C25 43.3696 22.3661 37.0107 17.6777 32.3223Z" fill="#C9FC7D"></path></svg>
</div>
<div class="marquee-css__item">
<p class="marquee-css__item-p">CSS Marquee</p>
<svg xmlns="http://www.w3.org/2000/svg" width="100%" viewbox="0 0 50 50" fill="none" class="marquee-css__item-svg"><path d="M17.6777 32.3223C12.9893 27.6339 6.63041 25 0 25C6.63041 25 12.9893 22.3661 17.6777 17.6777C22.3661 12.9893 25 6.63041 25 0C25 6.63041 27.6339 12.9893 32.3223 17.6777C37.0107 22.3661 43.3696 25 50 25C43.3696 25 37.0107 27.6339 32.3223 32.3223C27.6339 37.0107 25 43.3696 25 50C25 43.3696 22.3661 37.0107 17.6777 32.3223Z" fill="#C9FC7D"></path></svg>
</div>
</div>
</div>
HTML structure is not required for this resource.
Step 2: Add CSS
CSS
.marquee-css {
color: #efeeec;
background-color: #000;
width: 100%;
max-width: 42em;
display: flex;
position: relative;
overflow: hidden;
}
.marquee-css__list {
flex: none;
align-items: center;
display: flex;
position: relative;
}
.marquee-css__item {
grid-column-gap: 1em;
grid-row-gap: 1em;
flex: 0;
align-items: center;
padding-top: 1em;
padding-bottom: 1em;
padding-right: 1em;
display: flex;
}
.marquee-css__item-p {
white-space: nowrap;
margin-bottom: 0;
font-size: 1.5em;
line-height: 1;
}
.marquee-css__item-svg {
width: 1em;
}
/* CSS Keyframe Animation */
@keyframes translateX {
to {
transform: translateX(-100%);
}
}
[data-css-marquee-list] {
animation: translateX 30s linear;
animation-iteration-count: infinite;
animation-play-state: paused;
}
Step 2: Add custom Javascript
Custom Javascript in Webflow
In this video, Ilja gives you some guidance about using JavaScript in Webflow:
Step 2: Add Javascript
Step 3: Add Javascript
Javascript
// Note: The Javascript is optional. Read the documentation below how to use the CSS Only version.
function initCSSMarquee() {
const pixelsPerSecond = 75; // Set the marquee speed (pixels per second)
const marquees = document.querySelectorAll('[data-css-marquee]');
// Duplicate each [data-css-marquee-list] element inside its container
marquees.forEach(marquee => {
marquee.querySelectorAll('[data-css-marquee-list]').forEach(list => {
const duplicate = list.cloneNode(true);
marquee.appendChild(duplicate);
});
});
// Create an IntersectionObserver to check if the marquee container is in view
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
entry.target.querySelectorAll('[data-css-marquee-list]').forEach(list =>
list.style.animationPlayState = entry.isIntersecting ? 'running' : 'paused'
);
});
}, { threshold: 0 });
// Calculate the width and set the animation duration accordingly
marquees.forEach(marquee => {
marquee.querySelectorAll('[data-css-marquee-list]').forEach(list => {
list.style.animationDuration = (list.offsetWidth / pixelsPerSecond) + 's';
list.style.animationPlayState = 'paused';
});
observer.observe(marquee);
});
}
// Initialize CSS Marquee
document.addEventListener('DOMContentLoaded', function() {
initCSSMarquee();
});
Step 3: Add custom CSS
Step 2: Add custom CSS
Custom CSS in Webflow
Curious about where to put custom CSS in Webflow? Ilja explains it in the below video:
CSS
/* CSS Keyframe Animation */
@keyframes translateX {
to {
transform: translateX(-100%);
}
}
[data-css-marquee-list] {
animation: translateX 30s linear;
animation-iteration-count: infinite;
animation-play-state: paused;
}
Implementation
Attributes
The marquee is targeted via the attribute [data-css-marquee]
. The part that is moving on the X axis is targeted by the attribute [data-css-marquee-list]
.
Speed
The speed of the marquee can be changed in the JavaScript by changing the const pixelPerSecond = 75;
variable. Make it higher to go faster.
Functions of the script
- The CSS animation will be paused when out of view.
- The width of the
[data-css-marquee-list]
element is used to calculate the animation duration. - The
[data-css-marquee-list]
is duplicated to create the looping effect.
CSS Only version
Note: For the CSS Only version you don't need the javascript part of this resource. This removes the automatically speed calculation, duplication of the list and the in-view observer.
- Step 1: Duplicate the
[data-css-marquee-list]
. - Step 2: Fine-tune the
animation: translateX 30s linear;
speed to match the desired result. - Step 3: Remove the line
animation-play-state: paused;
from the CSS.
/* CSS Keyframe Animation */
@keyframes translateX {
to {
transform: translateX(-100%);
}
}
[data-css-marquee-list] {
animation: translateX 30s linear; /* Tweak this number in seconds */
animation-iteration-count: infinite;
/* Removed: animation-play-state: paused; */
}
Resource Details
Last updated
February 27, 2025
Type
The Vault
Category
Sliders & Marquees
Need help?
Join Slack