Using CSS mask-image in marquee swiper

I want to create a marquee logo slider with a 'fade' effect on the left and right sides. I already know how to make a basic marquee logo swiper, but while searching, I discovered the mask-image CSS property!

Great! To achieve the fade effect on the left and right sides of your marquee logo slider, you can use a linear-gradient with the mask-image CSS property. Here's an example of how you can apply it:

In this code:

Use offset in gradient

Instead of using percentage you can have fixed gradient size by using a custom property like so:

.logo-swiper {
--mask-offset: 3rem;
mask-image: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) calc(0% + var(--mask-offset)), rgba(0,0,0,1) calc(100% - var(--mask-offset)), rgba(0,0,0,0) 100%);
}

This gradient will make the edges of your marquee slider fade out, creating the desired effect.

Example

See the red boxes on the left and right sides of the marquee slider? That's the fade effect created by the mask-image property.

Lofoten
Lofoten
Lofoten
Lofoten
Lofoten
Lofoten
Lofoten

Good luck sliding into infinity and beyond! 🚀