If we need to set the unit of text to EM. What should we do?
PX is a pixel, is the unit relative to the screen resolution, EM is relative to the browser default font size units, such as in the browser, the default text size is 16px, then the default 1em=16px. If we need to set the size of the text to EM, Then we need to calculate the size of the text we need to set relative to the default font size in multiples. For example, we want to set the font to 12PX, then 12/16=0.75em. We want to set the font unit to 10px, then 10/16=0.625em. This conversion can be cumbersome, usually we will change the body's default font to 10px, that is body{font-size:62.5%;} So when we want to set the font to 12 pixels, it is 12/10=1.2em. In fact, the calculation method has not changed, but it is very convenient to calculate.
Why would I set the unit of text to em?
Here are the reasons for the excerpt from the Bad Monk's blog HTTP://BLOG.SINA.COM.CN/ENXIAOP:
"Usually use PX to define the font, so the browser can not enlarge the font function, and most of the foreign sites are available under IE." because: 1. IE cannot adjust the font size of those using PX as unit; 2. Most of the foreign sites can be adjusted because they use the EM as font units; 3. Firefox can adjust px and em, but more than 96% of Chinese netizens use IE (or kernel). ”
Text Size units em and px