🔄 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 同理用高度)。