Most browsers set 16px as the default font size. This is a universal web standard.
/* Check current root element size */
html {
font-size: 16px; /* default value */
}
/* Common adjustment method */
html {
font-size: 62.5%; /* sets root element to 10px (16px * 62.5% = 10px) */
}
如果預設是16px,從21px要換算成rem
21 ÷ 16 = 1.3125rem
這樣換算有點麻煩,所以有的人會直接把預設字型改成62.5%
那就只要這樣算就好了:
(21 ÷ 10 = 2.1)