CSS Gradient Generator
Build linear or radial gradients and copy the generated CSS
CSS Gradient Generator — what it does
Choose linear or radial, pick two colours, set the angle, and copy the generated CSS gradient. The preview updates as you adjust, so you can judge the result the way it will actually render rather than imagining what a set of numbers will look like in the browser.
Worked example
Three gradients produced with the controls; the declaration is exactly what the Copy button copies.
| Type | Angle | Colours | Generated declaration |
|---|---|---|---|
| Linear | 135 (default) | #1e5eff → #00b8a9 | background: linear-gradient(135deg, #1e5eff, #00b8a9); |
| Linear | 90 | #0f766e → #facc15 | background: linear-gradient(90deg, #0f766e, #facc15); |
| Radial | (ignored) | #0f766e → #facc15 | background: radial-gradient(circle, #0f766e, #facc15); |
Colours are written in the lower-case hex the colour picker returns; the radial type is always a circle centred in the box and does not use the angle.
When this tool helps
- Building a hero or section background that needs more depth than a flat colour but no image file.
- Creating a gradient button or badge that matches brand colours without exporting a PNG.
- Producing a soft overlay so white text stays readable over the top of a photograph.
How to use it
- Choose linear or radial gradient.
- Set the angle for a linear gradient.
- Pick the first and second colours.
- Copy the generated CSS into your stylesheet.
Accuracy, limits, and good practice
- Gradients between colours far apart on the wheel often pass through a muddy middle; picking neighbouring hues keeps the blend clean.
- In CSS, 0deg runs bottom to top and 90deg runs left to right — the opposite of what many design tools show.
- Gradients are backgrounds, so pair them with a background-color fallback if you support very old rendering environments.
Frequently asked questions
Can I add more than two colour stops?
The generator handles two. CSS itself accepts any number, so paste extra stops into the generated declaration by hand.
Which is better for a page background?
Linear for directional depth across a section; radial for a glow or spotlight effect centred behind a focal element.
Do gradients cost more to render than images?
No, they are usually cheaper. A gradient adds no network request and scales to any size without quality loss.
What happens if I type an angle outside 0–360, or leave it blank?
The number is passed through unchanged: 450 becomes linear-gradient(450deg, …), which browsers treat as 90deg, and a blank or non-numeric angle is written as 0deg.
Can I set the direction with keywords such as to right?
No. The angle box only accepts a number and the output always uses degrees; 90deg is the same direction as "to right" and 180deg as "to bottom". There is also no way to add transparency, because the colour pickers return opaque hex values.
Related tools on this site
- Unicode Escape Converter — Encode text as Unicode escapes or decode escape sequences
- CSS Box Shadow Generator — Design a box shadow visually and copy production-ready CSS
- Join Lines — Combine multiple lines using spaces, commas, or a custom separator
Further reading: Cleaning Up Text You Pasted From Somewhere Else
Everything above runs inside this page. CSS Gradient Generator needs no account, no upload, and no server round trip — close the tab and nothing is left behind.
CSS 漸層生成器能做什麼
選擇線性或放射漸層、挑好兩個顏色、設定角度,就能複製產生的 CSS 漸層。預覽會即時更新,讓你直接看到瀏覽器實際算出的效果,不必憑一組數字想像結果。
實際範例
以控制項做了三組漸層;表中的宣告就是按下複製時複製的內容。
| 類型 | 角度 | 顏色 | 產生的宣告 |
|---|---|---|---|
| 線性 | 135(預設值) | #1e5eff → #00b8a9 | background: linear-gradient(135deg, #1e5eff, #00b8a9); |
| 線性 | 90 | #0f766e → #facc15 | background: linear-gradient(90deg, #0f766e, #facc15); |
| 放射 | (忽略) | #0f766e → #facc15 | background: radial-gradient(circle, #0f766e, #facc15); |
顏色以色彩選擇器回傳的小寫十六進位寫法呈現;放射型一律是置中的圓形,不看角度。
什麼時候用得上
- 製作需要層次感、又不想額外載入圖檔的主視覺或區塊背景。
- 做出符合品牌色的漸層按鈕或標籤,不必匯出 PNG。
- 疊一層柔和遮罩,讓白色文字壓在照片上仍然清楚可讀。
使用步驟
- 選擇線性或放射漸層。
- 為線性漸層設定角度。
- 挑選第一個與第二個顏色。
- 把產生的 CSS 複製進樣式表。
精確度、限制與實務建議
- 色環上距離很遠的兩色,中間常會出現濁色;選相鄰色相能讓過渡更乾淨。
- CSS 中 0deg 是由下往上、90deg 是由左往右,與許多設計工具的標示相反。
- 漸層屬於背景,若需支援極舊的環境,建議同時保留 background-color 作為後備。
常見問題
可以設定超過兩個色停點嗎?
產生器目前支援兩個。CSS 本身不限數量,可在產生的宣告中手動加入更多色停點。
頁面背景該用哪一種?
整段區塊要方向性層次用線性;想在焦點元素後方做光暈或聚光效果則用放射。
漸層會比圖片耗資源嗎?
不會,通常更省。漸層不需額外網路請求,放大到任何尺寸也不會失真。
角度打到 0–360 以外或留空會怎樣?
數字原樣帶過去:450 會變成 linear-gradient(450deg, …),瀏覽器會把它當 90deg;留空或填非數字則寫成 0deg。
可以改成 to right 這類方向關鍵字嗎?
不行,角度欄只接受數字,產生的宣告一律以度數表示;90deg 等同「to right」,180deg 等同「to bottom」。也沒辦法加透明度,因為色彩選擇器回傳的都是不透明的十六進位色碼。
本站相關工具
- Unicode 跳脫字元轉換 — 將文字編碼為 Unicode 跳脫字元或進行解碼
- CSS 陰影生成器 — 以視覺方式設計方塊陰影並複製 CSS
- 合併文字行 — 使用空格、逗號或自訂分隔符合併多行文字
延伸閱讀: 清理從別處貼上的文字
以上步驟全部在這個頁面內完成,CSS 漸層生成器 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。