CSS 尺寸单位(px rem em vh)

界面字号阶梯优先 rem;必须时再用 px 画细边框。

อัปเดต:

单位相对什么典型用途
pxDevice pixel (CSS pixel)Borders, precise icons
remRoot element font-sizeType scale, spacing
emParent font-sizeComponent-local sizing
%Parent propertyWidths, flexible layouts
vw1% viewport widthFull-bleed sections
vh1% viewport heightHero height (mind mobile UI)
vmin / vmaxSmaller/larger viewport sideSquare-ish responsive sizing
chWidth of “0” glyphCode blocks, monospace fields
exx-height of fontRare fine typography
svh / lvh / dvhSmall/large/dynamic viewportMobile browser chrome-safe height

หมายเหตุ