🧮 Rem to Px Converter
Convert rem values from a spec or design file back to pixels using the current root font size for fixed-size contexts.
📐 工作原理與說明
px = rem × 根字號 root(rem 值乘以當前根元素 font-size)。校驗:rem 與 root 均須填寫且為有限數值,root 必須大於 0;預設、0、負值或非數字都停止計算並清空舊結果,不回落 16px。判據:結果保留兩位小數,同步顯示「1rem = root px」基準說明,root 改變時換算同比例縮放。
把以 rem 為單位的標註或設計稿按當前根字號反算為畫素,用於需要固定尺寸的場景或與設計師核對標註。
Formula & Standard References
| Item | Formula / Note | Source / Standard |
|---|---|---|
| Reverse conversion | px = rem x root font size, 16 px by default | CSS Values and Units Level 4 |
| Query units | em and rem in media queries resolve against the initial size | CSS Media Queries Level 4 |
| Rounding error | keep two decimals to avoid accumulated rounding drift | CSS Values and Units Level 4 |
⚠️ 使用說明與注意事項
- px = rem × 根字號;根字號改變時同一 rem 對應的 px 會整體變化。
- 固定尺寸場景(如海報、原生 App 內嵌 WebView)常用 px;自適應網頁推薦 rem。
- 結果四捨五入到 2 位小數。
📏 常用尺寸速查表(root = 16px)
| rem | px | 常見用途 |
|---|---|---|
| 0.5 | 8 | 小間距 / 描邊 |
| 0.75 | 12 | 輔助文字 |
| 0.875 | 14 | 正文小字 |
| 1 | 16 | 正文基準 |
| 1.25 | 20 | 小標題 |
| 1.5 | 24 | 標題 / 間距 |
| 2 | 32 | 區塊標題 |
| 3 | 48 | 大標題 |
| 4 | 64 | 頁面主標題 |
若採用 62.5% 根字號方案(1rem=10px),上表 px 值 = rem × 10,例如 1.6rem→16px、2.4rem→24px。