The meaning of 1rem, 1em, 1vh, 1px

rem

Rem is the entire length relative to the root element <html> element. The usual practice is to set a font size for html elements, and then the length unit of other elements is rem.

in

  • The em of the font size of the child element is relative to the font size of the parent element
  • The width/height/padding/margin of the element is relative to the font-size of the element if em is used

vw / vh

The full names are Viewport Width and Viewport Height. The width and height of the window are equivalent to 1% of the screen width and height. However, the% unit is more suitable when dealing with width, and the vh unit is better when dealing with height.

px

px pixels (Pixel). Relative length unit. The pixel px is relative to the monitor screen resolution.

Front-end training

Guess you like

Origin blog.csdn.net/msjhw_com/article/details/109065881