CSS-Verlaufs-Generator

So wird es benutzt 3 Schritte
  1. Wählen Sie den Verlaufsart und legen Sie Winkel oder Mittelpunkt fest.
  2. Legen Sie Farbstopp 1 und Farbstopp 2 samt Position fest; für eine weitere Farbe setzen Sie Einen dritten Farbstopp hinzufügen.
  3. Drücken Sie Verlaufs-CSS kopieren und fügen Sie es in Ihr Stylesheet ein.
Generierter CSS-Verlauf

So funktioniert dieses Werkzeug

Die drei Verlaufsfunktionen unterscheiden sich darin, wie sie zwischen Farben wandern. Ein linearer Verlauf läuft entlang einer Geraden im angegebenen Winkel, wobei 0deg nach oben zeigt und die Werte im Uhrzeigersinn steigen. Ein radialer Verlauf breitet sich von einem Punkt nach außen aus. Ein konischer Verlauf streicht um einen Punkt wie ein Uhrzeiger, weshalb er für Tortendiagramme und Farbkreise verwendet wird und nicht für Hintergründe.

Jeder Farbstopp trägt eine Position als Prozentwert entlang dieses Wegs. Die Stopps werden vor der Ausgabe sortiert, denn ein Stopp in falscher Reihenfolge ist gültiges CSS, erzeugt aber eine harte Kante statt eines Übergangs und wirkt dadurch wie ein Fehler statt wie eine Entscheidung. Zwei Stopps an derselben Position ergeben eine bewusste harte Kante — so entstehen Streifen. Der Winkelregler wird bei radialen Verläufen zu einer Mittelpunktsangabe, denn für eine Form, die sich in alle Richtungen ausbreitet, bedeutet ein Winkel nichts.

Einen Übergang bekommen, der stimmt

  • Verläufe zwischen Komplementärfarben laufen durch Grau: Die Interpolation führt durch den Farbraum zwischen Ihren beiden Stopps, und gegenüberliegende Farbtöne treffen sich in einer entsättigten Mitte. Ein dritter Stopp, der den Weg umlenkt, ist die übliche Abhilfe.
  • Die Stopp-Positionen sind, wo die Farbe rein ist: Der Übergang liegt dazwischen. Zwei Stopps bei 40% und 60% ergeben an beiden Enden eine volle Fläche und einen Übergang nur im mittleren Fünftel.
  • Ein Verlauf ist ein Bild, keine Farbe: Er gehört in background oder background-image und funktioniert nirgends, wo eine einfache Farbe erwartet wird, etwa bei border-color.
  • Bei dezenten Verläufen zeigt sich Banding: Ein langsamer Übergang über eine große Fläche stuft auf 8-Bit-Displays sichtbar. Mehr Kontrast zwischen den Stopps, eine kleinere Fläche oder eine feine Rauschebene verringern es.

Three functions, three different paths

A gradient is a blend along a path, and the three functions differ in what that path is.

  • Linear runs along a straight line at an angle you set. 0deg points up and angles increase clockwise, so 90deg runs left to right and 180deg top to bottom.
  • Radial spreads outward from a point. An angle means nothing to it; a centre position does.
  • Conic sweeps around a point like a clock hand. This is the one used for pie charts, colour wheels and progress rings, and it is rarely the right choice for a page background.

The [msm_tool slug="gradient-builder"] swaps the angle control for a centre position when you choose radial, because carrying an angle across would be offering a setting that does nothing.

Why gradients go grey in the middle

The single most common complaint, and it is not a bug.

Interpolation runs through the colour space between your two stops. Colours on opposite sides of the wheel — a blue and an orange, a red and a green — meet at a desaturated point on the way, and that point is grey or a muddy brown.

The fix is a third stop that steers the blend around rather than through the middle. Going from blue to orange, add a stop of a saturated violet or teal depending on which way round you want the transition to travel. Two stops give you no control over the path; three do.

Stop positions

Each stop carries a position as a percentage along the path, and the colour is pure at that position. The blend happens between them.

That means two stops at 40% and 60% give a solid band at each end and a transition confined to the middle fifth. It also means the stops must be in ascending order — an out-of-order stop is legal CSS but renders as a hard band rather than a blend, which reads as a bug rather than a choice. The builder sorts them before writing the value for that reason.

Hard stops make stripes

Put two stops at the same position and the colour changes with no transition at all. That is how every CSS stripe, check and split-background is built, and it is worth knowing because it turns the gradient functions into a general-purpose shape tool rather than only a blending one.

linear-gradient(90deg, #fff 0%, #fff 50%, #eee 50%, #eee 100%) is a two-colour split down the middle, and no image was involved.

A gradient is an image

This catches people out in a specific place. Gradients belong in background or background-image, and they will not work anywhere a plain colour is expected.

border-color: linear-gradient(...) does nothing. For a gradient border, either use border-image, or put the gradient on a wrapper and inset the content with padding. For gradient text, the usual technique is a background gradient with background-clip: text and transparent text colour — which needs a solid fallback colour, since a browser that ignores the clip shows invisible text.

Banding

A slow transition across a large area steps visibly on 8-bit displays, showing as faint bands rather than a smooth blend. It is most obvious on subtle gradients between similar dark colours, which is exactly where designers reach for them.

Three things reduce it: more contrast between the stops, a smaller area, or a very faint noise overlay on top. The noise trick works because the dithering breaks up the flat bands, and it is what most large hero gradients quietly use.

Performance and accessibility

Gradients are cheap to paint and cost nothing worth measuring as static backgrounds. Animating one is different: gradients are not interpolatable properties, so transitioning between two of them does not blend — it snaps. The usual approach is to stack two gradients and transition the opacity of the top one.

On accessibility: text over a gradient has no single background colour to test. Sample the lightest and darkest points the text actually crosses and make sure the worst of them meets the contrast minimum. A gradient that passes at one end and fails at the other is a gradient with unreadable text on part of it.

Häufig gestellte Fragen

Speziell zum CSS-Verlaufs-Generator. Allgemeinere Fragen zu dieser Kategorie werden auf der Kategorieseite beantwortet.

Die beiden Farben sind nahezu gegenüberliegende Farbtöne, und der Weg dazwischen führt durch einen entsättigten Punkt. Ein dritter Stopp lenkt den Übergang darum herum.
Nach oben. Die Winkel steigen im Uhrzeigersinn, 90deg läuft also von links nach rechts und 180deg von oben nach unten.
Wenn die Farbe um einen Punkt streichen soll statt über eine Strecke — Tortendiagramme, Farbkreise, Fortschrittsringe. Für einen Seitenhintergrund ist er selten richtig.
Setzen Sie zwei Stopps auf dieselbe Position. Die Farbe wechselt ohne jeden Übergang, und genau so ist jedes Streifenmuster gebaut.
Nicht direkt — ein Verlauf ist ein Bild und border-color nimmt eine Farbe. border-image oder ein Hintergrund auf einem umgebenden Element sind die üblichen Wege.

Abonniere Benachrichtigungen zu neuen Tools, Funktionen und Produktivitätstipps.