🔄 Viewport Unit (vw/vh) Converter

Convert between viewport units and pixels: vw and vh are 1% of the viewport width and height, handy for full-screen layouts.

📐 工作原理与说明
px → vw:vw = px ÷ 视口宽度 × 100;vw → px:px = vw × 视口宽度 ÷ 100(vh 同理按高度计算)
vw 与 vh 分别是视口宽、高的 1%,因此换算需给定基准视口尺寸。按宽度换算时以视口宽为基准、按高度换算时以视口高为基准,反向(vw/vh → px)则为乘算,用于替代写死的 px 实现自适应间距与全屏布局。

Formula & Standard References

Item Formula / Note Source / Standard
Viewport percentage 1vw is one percent of viewport width, 1vh of height CSS Values and Units Level 4
Mobile viewport height browser chrome makes 100vh overflow, so use svh, lvh or dvh CSS Values and Units Level 4
Extreme units vmin follows the shorter axis and vmax the longer CSS Values and Units Level 4
⚠️ 使用说明与注意事项

📺 常见视口断点参考

设备宽度(px)典型 vw 示例
手机360–414100vw ≈ 360–414px
平板768–102450vw ≈ 384–512px
笔记本1280–144050vw ≈ 640–720px
桌面192050vw = 960px

换算公式:vw = px ÷ 视口宽度 × 100;px = vw ÷ 100 × 视口宽度(vh 同理用高度)。