📐 CSS Units Converter

Loading... Thanks for your rating!
Updated: 2026-07-11
Ad Space - Top (728×90)

🔢 CSS单位转换

⚙️ 基准值设置

px(浏览器默认16px)
px
px
px(用于em单位计算)

📊 转换结果

输入数值并点击转换。

📋 常见CSS单位速查表

单位类型相对基准常见用途
px绝对1px = 屏幕1个像素边框、阴影、精确尺寸
rem相对根元素字体大小全局字体大小、间距
em相对当前元素字体大小组件内边距、按钮
vw视口相对视口宽度的1%全屏布局、响应式字体
vh视口相对视口高度的1%全屏高度、页面区块
%相对父元素相应属性宽度、高度、定位
pt绝对1pt = 1/72英寸打印样式
cm绝对物理厘米打印样式
in绝对物理英寸打印样式
ex相对当前字体x-height垂直对齐、排版
ch相对当前字体0字符宽度等宽布局、字符计数

❓ Frequently Asked Questions

❓ What is the difference between px, rem, and em?
px (pixels) is absolute — 1px equals one screen pixel. rem is relative to the root element's font size (usually 1rem = 16px browser default). em is relative to the current element's font size. em can cascade unpredictably in nested elements.
❓ When should I use rem vs em?
Use rem for font sizes and spacing as it only depends on root font size. Use em for component-scale elements like button padding. Use px for borders, shadows, and fine details. Use vw/vh for full-screen layouts and responsive designs.
❓ How are vw and vh calculated?
1vw = 1% of viewport width. 1vh = 1% of viewport height. For a 1200px viewport, 10vw = 120px. Note: mobile browsers may include address bar in 100vh — use dvh (dynamic viewport height) as alternative.
❓ What is the browser default font size?
Most browsers default to 16px (configurable in settings). This equals 1rem by default. Using rem units respects user font size preferences for better accessibility.
❓ When to use pt, cm, mm in CSS?
pt (points, 1pt = 1/72 inch) is for print stylesheets. cm, mm, in are physical units mainly for @media print queries. On screens, actual sizes depend on screen DPI/PPI.

💡 This tool runs entirely in your browser — no data is uploaded to any server · Refresh if you encounter any issues