Gallery✨ Premium

Gradient Fade

Indigo-to-magenta gradient words slide left and fade softly at both edges, over any background, light or dark.

CSSGradient

Updated

This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. Gallery has 44 effects, including 6 free. Explore the category →

3 usage examples

A recording studio's slogan — between the content and the footer — Gradient Fade example 1

① A recording studio's slogan — between the content and the footer

WhenBelow Studio Arquelle's three rooms (live, mixing, vocal booth), a 26 px bold band runs “Record. Mix. Master.” above the footer columns: address, links, “Book a session” button.
WhyThe band closes the page without a hard line: words appear and vanish into the dark thanks to the fade, and the purple gradient echoes the lighting of room B.
Settingsdata-speed="45", --gfmq-size: 26px, --gfmq-space: 44px, --gfmq-fade: 70px, --gfmq-bg: transparent, --gfmq-height: auto; default gradient colours.
An illustrator's fields — under her name, on a cream background — Gradient Fade example 2

② An illustrator's fields — under her name, on a cream background

WhenAt the top of Odile Marquesse's portfolio, a 330 px band under her large name runs her fields in small capitals (children's books, posters, maps, linocut, editorial), above the grid of her pictures.
WhyThe background is light: exactly where the old version failed. The mask melts the words into the cream with no dark box, and the brick-to-rust gradient matches the italic in her name.
Settingsdata-speed="28", --gfmq-color: #7c2d12, --gfmq-to: #c2410c, --gfmq-size: 13px, --gfmq-space: 26px, --gfmq-fade: 36px, --gfmq-button: #7c2d12, --gfmq-button-size: 22px, 330 px wide.
An independent bookshop's shelves — a band of gradient links below the hero — Gradient Fade example 3

③ An independent bookshop's shelves — a band of gradient links below the hero

WhenOn the Volubrine bookshop home page, below the headline and the pick of the week, the eight shelves (fiction, crime, comics, children, poetry…) pass in 38 px italics, from ink blue to plum; each shelf is a link to its page.
WhyThe band acts as a discovery menu: it shows the range of the stock in one line, resting the mouse stops it for a click, and the edge fade lets the words come and go with no hard cut on the cream paper. With the keyboard, Tab visits the eight links, band held still.
Settingsdata-speed="55", --gfmq-color: #1e3a8a, --gfmq-to: #7e22ce, --gfmq-size: 38px, --gfmq-space: 36px, --gfmq-fade: 60px, --gfmq-button: #1e3a8a, --gfmq-button-size: 24px, --gfmq-bg: transparent, --gfmq-height: auto; an <a href> in each <li>, serif italics set by the page stylesheet.

How it works

The edge fade is a mask set on .gfmq-viewport: mask-image makes the band transparent over its first and last 100 pixels (--gfmq-fade). Whatever the page behind shows comes through. The old version painted two #0a0a0f veils over the text; on a white background or a photo, they turned into two dark rectangles.

The gradient is painted into the letters with background-clip: text, on each list: it starts at --gfmq-color at the beginning of the list and reaches --gfmq-to at its end. Since the script copies the whole list, every duplicate carries exactly the same gradient, and moving from one duplicate to the next goes unnoticed.

The number of duplicates is worked out from the band's real width, which removes the gap that opened on the right past roughly 1,000 px. Scrolling runs at 65 px per second (data-speed), stops under the mouse and freezes with the Pause button set at the end of the band, outside the fade.

Accessibility

  • Stopping the motion: hover over the band, or the Pause button (aria-pressed) usable by click, finger and keyboard — the motion lasts over 5 seconds, so WCAG 2.2.2 requires it.
  • Real text: the words are HTML text, selectable and read by screen readers; only the duplicates, marked aria-hidden="true", are skipped. Before the repair, every word was announced twice.
  • Legibility: on #0a0a0f, the starting indigo reaches 4.4:1 and the magenta 5.7:1. In the faded areas the text deliberately turns pale: do not put essential information only there; it is readable in the middle.
  • Reduced motion: with prefers-reduced-motion: reduce, the band stops on the original list, keeps its gradient and faded edges, and can be scrolled by hand; when it overflows, it also takes keyboard focus (Tab) and scrolls with the arrow keys.
  • Focus: a link in the band reached with the keyboard holds the band still at its start and brings it into view; links in the duplicates are skipped (tabindex="-1").

Browser compatibility

CSS mask (mask-image, with its -webkit- form for Chrome before 120 and Safari before 15.4), gradient text (background-clip: text, with -webkit-background-clip), CSS animation and 4.5 KB of commented JavaScript. Measured in Chromium 151, Firefox 153 and WebKit 26.5, over a dark and a white background: faded edges with no dark strip, no gap at 1,900 px, 0 errors.

Chrome 74+✓ Full (measured)
Firefox 69+✓ Full (measured)
Safari 13.1+✓ Full (WebKit engine measured)
Edge 79+✓ Full (Chromium engine)
Mobile iOS 13.4+✓ Full (WebKit engine measured)
Android Chrome 74+✓ Full (Chromium engine)

Without CSS masks, the edges are sharp. Without background-clip: text, the words show in plain --gfmq-color (the text colour stays declared). Without JavaScript, the words stand still and can be scrolled by hand.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0193-root" data-speed="65" data-direction="left">
  <div class="gfmq-band">
    <div class="gfmq-viewport">
      <div class="gfmq-track">
        <ul class="gfmq-group" role="list">
          <li>Your slogan</li>
          <li>Second message</li>
        </ul>
      </div>
    </div>
    <button type="button" class="gfmq-toggle" aria-pressed="false" aria-label="Pause"></button>
  </div>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Messages (HTML — <li> of .gfmq-group) 4 messages Written once; the script adds the duplicates.
--gfmq-color → --gfmq-to #6366f1 → #d946ef Start and end of the gradient. On a light background, pick two dark hues.
--gfmq-fade 100px Width of each faded edge. 0 for sharp edges.
data-speed / data-direction 65 / left Pixels per second and direction (right for the reverse).
--gfmq-size / --gfmq-space 1.5rem / 4rem Word size and gap between two messages.
--gfmq-height / --gfmq-bg / --gfmq-padding 180px / #0a0a0f / 1rem 0 Demo frame; auto, transparent, 0 inside a page.
--gfmq-button / --gfmq-button-size rgba(255, 255, 255, .8) / 2rem Hue and diameter of the Pause button.

FAQ

Yes. The mask paints nothing: it makes the band transparent at its edges, so whatever background image is there shows through. The only condition: the band must not have an opaque background (--gfmq-bg: transparent).
It is painted on each list, original and duplicates. That is what hides the seam: one continuous gradient across the whole track would shift colour on every lap and jump when the loop restarts.
Yes, by replacing the mask rule on .gfmq-viewport with a one-edge gradient, for instance linear-gradient(to right, transparent, #000 var(--gfmq-fade)) to fade the left side only.