Web Design Unit px, em, rem, vm, vh,%

px(pixels)

Pixel (px) is an absolute unit , because no matter how change other settings, specify the value of the pixel is not going to change.

device or image px is a minimum point, such as is often heard in computer 1024x768 pixels, and the horizontal direction is represented by 1024 pixels, the vertical direction is 768 pixels.

(There is a special case, modify the screen resolution, px will change)

in

em the same font size of the current element (more specifically, a width of the uppercase letter M). Reference substance is the parent element of font-size, having characteristics inherited. If self-defined font-size is calculated by itself (the browser's default font is 16px).

em is the most commonly used Web development relative units .

rem

rem em and is very similar, it is always equal to the default font size of the size of the base; html element is relative to the root of the inheritance of the font size will not work. So, just by setting the root element's font size, you can adjust the ratio of the entire page.

vm vh

vm: view width shorthand means 1/100 of the width of the visible window.

vh: view height shorthand, 1/100 refers to the height of the visible window.

percentage%

After addition percentage of sub-elements, sub-elements according to the width and height value of the parent element, parent element changes the width and height, width and height of the sub-elements also change.

Guess you like

Origin www.cnblogs.com/yaokai729/p/11326369.html