CSS

CSS 单位转换

px、rem、em、vw、vh 等单位互转

🔒 100% client-side — your data never leaves this page
px
px
px
Presets
pxPixels
px
remRoot EM
rem
emElement EM
em
vwViewport Width %
vw
vhViewport Height %
vh
ptPoints
pt
%Percent (of root)
%
cmCentimeters
cm
mmMillimeters
mm
inInches
in

About this tool

实时转换所有常用 CSS 单位。在任意单位输入框输入数值,其他所有单位即时更新。可自定义根字体大小(用于 rem/em 计算)和视口尺寸(用于 vw/vh 计算),内置移动端、平板、桌面和 4K 预设。

Frequently Asked Questions

What is the difference between rem and em?

rem (root em) is relative to the root element font size (usually 16px by default). em is relative to the font size of the element itself or its parent. rem is more predictable and widely recommended for layout sizing.

What is 1rem in pixels?

By default, 1rem equals 16px (the default browser font size). If you change the root font size with html { font-size: 62.5% }, then 1rem equals 10px, making calculations easier.

How are vw and vh calculated?

1vw equals 1% of the viewport width, and 1vh equals 1% of the viewport height. These values depend on the browser window size, which you can customize in this tool's settings.