CSS UNITS

屏幕单位换算,px rem em 一秒通。

在 px、rem、em、pt、% 之间即时互转,可设根字号与视口宽度,并附常用参考表,前端切图与移动端适配更顺手。纯前端本地处理。

常用参考表(根字号 16px)

单位换算怎么算?

rem 相对根字号(默认 16px),em 相对当前字号(此处按根字号估算),pt 是印刷点(1px = 0.75pt),% 在宽度场景下相对视口(1vw = 视口宽/100)。改上面任意值,下方结果实时联动。

示例与注意事项Example & notes

一个例子A worked example

设计稿 375px 宽、按钮宽 88px:根字号 16px 时等于 23.4375rem,页面同时给出 vw 与百分比换算。A design at 375 px with an 88 px button equals 23.4375 rem at a 16 px root; vw and percentage values are given too.

注意事项Things to watch

相关问答More Q&A

该选 rem 还是 vw?rem or vw — which one?

需要跟随用户字号缩放用 rem;需要严格按设计比例铺满用 vw。Use rem when text must respect user font settings, vw when the layout must scale with the viewport.

支持小程序 rpx 吗?Does it support rpx?

支持,按 750 设计稿的换算规则给出 rpx 值。Yes — rpx values follow the standard 750-unit design width.

深入阅读

觉得好用?Found it useful?