units in css

There are many length units when writing CSS styles. Know the common and uncommon ones.

There are two types: absolute units and relative units.

Absolute units: will not change due to changes in the size of other elements.

px: Pixel, a point on a computer screen.

pt: point

pc: itchy

in: 寸 1in = 96px = 72pt = 6pc = 2.54cm

cm, mm, q are not commonly used

Relative units: will change relative to the size of an element.

rem: the size of the font relative to the html tag

em: the size of the font relative to the parent element

%: relative to the width of the parent element or the size of the font

vw: 1vw == 1% of the width of the viewport (viewable area of ​​the browser)

vh: 1vh == 1% of the height of the viewport (viewable area of ​​the browser)

vmin/vmax: The smaller/larger dimension of the 1% viewport width and height.

A brief summary.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325052390&siteId=291194637