Utvikling · verktøy

CSS-gradientgenerator

Velg gradienttype, retning og minst to fargestopp for å generere CSS.

Kjøres i nettleseren. Ingen opplasting.

Values are processed locally in this browser.

Result

—

Om verktøyet

CSS-gradientgenerator sem complicação.

Farger og verdier valideres og behandles lokalt. Kontroller resultatet i prosjektet ditt, og test kontrasten for tekst som legges over gradienter.

Veiledning

Slik bruker du CSS-gradientgenerator

The CSS Gradient Generator writes one line of CSS for a linear or radial colour gradient. You pick the type, set an angle for linear gradients, and enter two or three colours as hex codes. It returns a background rule that you copy into your stylesheet. It shows no colour preview, it has no stop positions, and it cannot tell you whether text on top of the gradient will be easy to read.

Slik gjør du

  1. Choose Linear or Radial as the gradient type.
  2. For a linear gradient, set the angle from 0 to 360 degrees. In CSS, 0 points up and the angle grows clockwise, so 90 points right and 180 points down. A radial gradient ignores the angle.
  3. Type the first and second colours as hex codes, either three digits like #f80 or six like #ff8800. The third colour is optional, and the # sign can be left out.
  4. Press Calculate, then Copy result and paste the line into your CSS. Open the page in a browser to see the real colours.

Eksempler

The starting values

Du skriver inn
Type
linear
Vinkel
135
Farge 1
#6D5EF5
Farge 2
#C7F36B
Du får
CSS
background: linear-gradient(135deg, #6D5EF5, #C7F36B);

An angle of 135 degrees runs from the top left towards the bottom right, with the first colour at the start of the line and the second at the end.

Kjørt med verktøyets egen kode.

The same colours as a radial gradient

Du skriver inn
Type
radial
Vinkel
135
Farge 1
#6D5EF5
Farge 2
#C7F36B
Du får
CSS
background: radial-gradient(#6D5EF5, #C7F36B);

The angle does not appear in the output. A radial gradient is written without a shape or size, so the browser uses its own defaults, which MDN gives as an ellipse that reaches the farthest corner.

Kjørt med verktøyets egen kode.

Three colours and short hex codes

Du skriver inn
Type
linear
Vinkel
90
Farge 1
#fff
Farge 2
#000000
Farge 3
#f00
Du får
CSS
background: linear-gradient(90deg, #FFFFFF, #000000, #FF0000);

Three-digit codes are expanded to six digits and the letters are made uppercase. The three colours are spaced evenly from left to right at 90 degrees.

Kjørt med verktøyets egen kode.

A colour name is refused

Du skriver inn
Type
linear
Vinkel
45
Farge 1
red
Farge 2
#123456
Du får
Feil
First color must be a 3- or 6-digit hex color, such as #336699.

Only hex codes are accepted. Names, rgb() and hsl() values are not, and neither are eight-digit hex codes with a transparency part. An angle above 360 is also refused.

Kjørt med verktøyets egen kode.

Når det er nyttig

  • Make a quick background for a hero banner, card or button without writing the syntax by hand.
  • Try two or three brand colours together and copy the rule straight into a stylesheet.
  • Learn how the angle of a linear gradient points, by changing it and reading the output.
  • Produce a starting rule that you then edit by hand to add stop positions or a custom shape.

Begrensninger

  • Only hex colours of three or six digits are accepted. There are no colour names, no rgb() or hsl() values, and no transparency.
  • A gradient has two or three colours spaced evenly. There are no stop positions, no hints and no repeating or conic gradients.
  • The angle runs from 0 to 360 and is rounded to one decimal place in the output. It is used for linear gradients only.
  • The tool prints text only. It has no preview, adds no fallback colour, and does not check contrast. Test your result in a browser.

Tips

  • Add a plain background-color line yourself as a fallback, in case the gradient does not load.
  • Check text contrast against the lightest and the darkest part of the gradient, not just the middle.
  • Pick the angle by thinking of an arrow: 90 runs left to right, 180 runs top to bottom, and 0 runs bottom to top.

Kilder

Vanlige spørsmål

Sobre CSS-gradientgenerator.

How does the angle work in a CSS linear gradient?

MDN explains that 0deg is the same as to top, and larger values turn clockwise. So 90deg goes to the right, 180deg goes down and 270deg goes to the left. The first colour sits at the start of that line and the last colour at its end.

Why is my radial gradient ignoring the angle?

A radial gradient spreads outward from a centre point, so it has no direction to rotate. The tool leaves the angle out of the radial line on purpose. If you want the centre moved or a circle instead of an ellipse, edit the CSS by hand.

Can I use colour names, rgb() or transparency?

Not in this tool. It accepts only three-digit or six-digit hex codes and shows an error for anything else. If you need a transparent colour, paste the result into your stylesheet and replace the hex code with an rgba() value yourself.

Can I add more colours or set where each one sits?

No. The tool allows up to three colours with equal spacing. CSS itself allows more colours and positions such as a colour followed by 40%, so you can add them by hand after pasting the line.

Why did my hex code change case or length?

The tool tidies every colour into six uppercase digits, so #f00 becomes #FF0000 and #6d5ef5 becomes #6D5EF5. The colour is exactly the same. It also adds the # sign if you left it out.

Does it show a preview of the gradient?

No. You get the CSS text only. Paste it into a test page or your own project to see the gradient, and look at it on more than one screen, because colours can look different between displays.

Are my colours sent to a server?

No. The page says the values are checked and processed in your browser. The tool simply builds a text string from what you type and shows it on the page.

Hvordan bruker du CSS-gradientgenerator?

Velg gradienttype, retning og minst to fargestopp for å generere CSS.

Lastes dataene mine opp til en server?

Nei. Behandlingen skjer i nettleseren din, og opplysningene dine lastes ikke opp.