Convert pixel values to rem against a chosen root font size, the usual way to keep responsive and accessible layouts.
| 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 |
| 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。
输入:16px、根字号 16px。
处理:相除。
输出:1rem;根字号变则等比缩放。