CSS Box Shadow Generator
Design a box shadow visually and copy production-ready CSS
CSS Box Shadow Generator — what it does
Adjust horizontal and vertical offset, blur, spread, colour and opacity with live controls, and copy the resulting box-shadow declaration straight into your stylesheet. An inset option flips the shadow inward for pressed buttons and inner wells, so both directions of depth are covered without hand-editing values.
Worked example
Three shadows built with the controls; the declaration is exactly what the Copy button puts on the clipboard.
| Settings (x, y, blur, spread, opacity, colour) | Generated declaration |
|---|---|
| 0, 12, 30, 0, 18 %, #1e3a8a (the defaults) | box-shadow: 0px 12px 30px 0px rgba(30, 58, 138, 0.18); |
| 0, 4, 12, 0, 25 %, #000000 | box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.25); |
| 0, 2, 6, 1, 30 %, #0f172a, inset ticked | box-shadow: 0px 2px 6px 1px rgba(15, 23, 42, 0.30) inset; |
The colour is always written as rgba() with the opacity as a two-decimal alpha, and a zero offset is still written as 0px.
When this tool helps
- Designing card, modal and dropdown elevation that matches an existing design system's shadow scale.
- Creating the pressed or focused state of a button, where an inset shadow reads as physical depth.
- Reproducing a shadow you can see in a mock-up but do not have the source values for.
How to use it
- Set horizontal and vertical offsets to place the shadow.
- Adjust blur and spread until the edge softness looks right.
- Pick the shadow colour and opacity, and toggle inset if needed.
- Copy the generated CSS into your stylesheet.
Accuracy, limits, and good practice
- Subtle beats strong: low opacity around 0.08 to 0.15 with generous blur reads as real elevation, while dark solid shadows look dated.
- Vertical offset with almost no horizontal offset matches how overhead light works, which is why most interface shadows fall straight down.
- Shadows are painted outside the border box and do not affect layout, so they never push neighbouring elements around.
Frequently asked questions
What is the difference between blur and spread?
Blur softens the edge over a distance; spread grows or shrinks the shadow's size before blurring. Negative spread pulls it in tight.
Can I stack several shadows?
Yes, in CSS you can comma-separate multiple shadows on one property. Generate each layer here and join them with commas.
Do shadows hurt performance?
A handful is fine. Very large blur radii on many animated elements can cost paint time on low-end devices.
What if I type an opacity above 100?
The number is divided by 100 without being clamped, so 150 produces rgba(15, 23, 42, 1.50), which browsers treat as fully opaque, and a value such as 12.5 is rounded to 0.13. Keep opacity between 0 and 100.
Can I use units other than pixels, or negative offsets?
Every length is written in px; there is no em or rem option, so edit the unit after copying if you need it. Negative numbers are accepted and are the normal way to cast a shadow upward or to the left (a y of -4 gives 0px -4px …).
Related tools on this site
- List Formatter — Convert lines into bullets, numbers, CSV, or JSON
- Text Cleaner — Remove extra spaces, empty lines, and repeated lines
- Color Converter — Convert colors between HEX, RGB, and HSL formats
Further reading: Cleaning Up Text You Pasted From Somewhere Else
Everything above runs inside this page. CSS Box Shadow Generator needs no account, no upload, and no server round trip — close the tab and nothing is left behind.
CSS 陰影生成器能做什麼
用即時控制項調整水平與垂直位移、模糊、擴散、顏色與透明度,再把產生的 box-shadow 宣告直接複製進樣式表。內陰影選項可把陰影翻轉到內側,適合按下狀態的按鈕與凹槽效果,兩種深度方向都不必手改數值。
實際範例
以控制項做了三組陰影;表中的宣告就是按下複製時放到剪貼簿的內容。
| 設定(x、y、模糊、擴散、不透明度、顏色) | 產生的宣告 |
|---|---|
| 0, 12, 30, 0, 18 %, #1e3a8a(預設值) | box-shadow: 0px 12px 30px 0px rgba(30, 58, 138, 0.18); |
| 0, 4, 12, 0, 25 %, #000000 | box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.25); |
| 0, 2, 6, 1, 30 %, #0f172a,勾選 inset | box-shadow: 0px 2px 6px 1px rgba(15, 23, 42, 0.30) inset; |
顏色一律寫成 rgba(),不透明度化為兩位小數的 alpha;位移為 0 時仍寫成 0px。
什麼時候用得上
- 設計卡片、彈窗與下拉選單的層級陰影,並與既有設計系統的陰影階層一致。
- 製作按鈕的按下或聚焦狀態,內陰影能讓深度感更真實。
- 重現在設計稿上看到、但拿不到原始數值的陰影。
使用步驟
- 設定水平與垂直位移,決定陰影落點。
- 調整模糊與擴散,直到邊緣柔和度合適。
- 選擇陰影顏色與透明度,必要時切換為內陰影。
- 把產生的 CSS 複製進樣式表。
精確度、限制與實務建議
- 淡比濃好看:透明度約 0.08 至 0.15 搭配較大模糊,看起來才像真實層級;深而實的陰影顯得過時。
- 垂直位移大、水平位移接近零,符合頂光的物理直覺,這也是多數介面陰影都往正下方落的原因。
- 陰影繪製在邊框外且不影響版面配置,因此不會推擠周圍元素。
常見問題
模糊與擴散差在哪?
模糊是讓邊緣在一段距離內柔化;擴散則是在模糊前把陰影整體放大或縮小,負值會讓它更貼近元素。
可以疊多層陰影嗎?
可以,CSS 允許在同一屬性中用逗號分隔多組陰影。在這裡逐層產生後以逗號串接即可。
陰影會影響效能嗎?
少量無妨。但在大量會動的元素上使用超大模糊半徑,低階裝置的繪製時間會明顯增加。
不透明度打超過 100 會怎樣?
數字會直接除以 100、不設上限,所以 150 會變成 rgba(15, 23, 42, 1.50),瀏覽器視為完全不透明;12.5 這類值則四捨五入成 0.13。請把不透明度維持在 0 到 100 之間。
可以改成 px 以外的單位,或填負數位移嗎?
所有長度一律是 px,沒有 em 或 rem 的選項,需要的話複製後再手動改單位。負數可以填,而且是讓陰影朝上或朝左的正常做法(y 填 -4 會得到 0px -4px …)。
本站相關工具
延伸閱讀: 清理從別處貼上的文字
以上步驟全部在這個頁面內完成,CSS 陰影生成器 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。