🧮 Px to Rem Converter
Convert pixel values to rem against a chosen root font size, the usual way to keep responsive and accessible layouts.
📐 工作原理與說明
rem = px / root(root 為根元素 font-size,預設 16px)
rem 相對根元素字型大小:以根字號為基準換算,便於做響應式與可訪問性友好的佈局(使用者調整根字號時整體等比縮放),用於設計稿落地。
Formula & Standard References
| Item | Formula / Note | Source / Standard |
|---|---|---|
| Conversion | rem = px / root font size, 16 px by default | CSS Values and Units Level 4 |
| User zoom | rem layouts scale when users enlarge the default font size | WCAG 2.2 (1.4.4) |
| Root size changes | changing the root size shifts every rem value at once | CSS Values and Units Level 4 |
⚠️ 使用說明與注意事項
- rem 相對於根元素()的 font-size;修改根字號即可整體縮放頁面,便於響應式與無障礙。
- 瀏覽器預設根字號為 16px,很多團隊會把 :root 設為 62.5%(即 10px)讓 1rem=10px 方便心算。
- 結果保留 4 位小數,實際使用時通常取 2–3 位(如 1.5rem)。
📏 常用尺寸速查表(root = 16px)
| px | rem | 常見用途 |
|---|---|---|
| 8 | 0.5 | 小間距 / 描邊 |
| 12 | 0.75 | 輔助文字 |
| 14 | 0.875 | 正文小字 |
| 16 | 1 | 正文基準 |
| 20 | 1.25 | 小標題 |
| 24 | 1.5 | 標題 / 間距 |
| 32 | 2 | 區塊標題 |
| 48 | 3 | 大標題 |
| 64 | 4 | 頁面主標題 |
若採用 62.5% 根字號方案(1rem=10px),上表 rem 值直接乘以 1.6 即可,例如 16px→1.6rem、24px→2.4rem。