Units commonly used in css are hereby
-
window unit
-
vw (viewport width)
vw is calculated based on the width of the current window
-
vh (viewport height)
vh is calculated based on the height of the current window
-
vmin
The smaller value of the current vw and vh -
vmax
The larger value of the current vw and vh -
%
is calculated based on the parent element
-
px
absolute unit
-
-
px font unit
-
px
absolute unit
-
%
font-size
Calculated from the parent element's -
em
font-size
Calculated from the parent element's -
rem
font-size
Calculated according to the html tag
1em = 1rem = 100% = 16px
-
五大浏览器默认字体大小均是16px
The minimum font size of the five major browsers:
Chrome(87.0) | Firefox(83.0) | IE(5 7 8 9 10 11) | Edge(87.0) | Opera (72.0) | Safari (5.1.7) | |
---|---|---|---|---|---|---|
minimum font size | 6px | 0 | 0 | 0 | 12px | 0 |
Minimal font size for other browsers:
Sogou browser | 360 browser | QQ browser | UC Browser | Firefox | Star wish browser | |
---|---|---|---|---|---|---|
minimum font size | 12px | 12px | 12px | 12px | 0 | 12px |
When the font-size of html is set to be smaller than the minimum font size of the browser, the browser will still default to the minimum font size of the browser when rem is used in the page.