当前位置:网站首页>How rem is used

How rem is used

2022-07-05 03:28:00 Lao Zhang typed the code online

rem What is it? ?

rem Is the unit of font size relative to the root element
In the daily development process, we usually put the root element (html/body) The font of is set to 10px, Convenient for us to calculate ( At this point, the of the child element 1rem Equivalent to 10px)

rem And em The difference between , Advantages and disadvantages of each ?

em Sub element font size of em Is the font size relative to the parent element
rem Is based on the font size of the root element

em Different elements have different references ( Are all the parent elements of this element ), So it's inconvenient to calculate , by comparison rem There is only one reference (html Elements ), This makes the calculation clearer .

原网站

版权声明
本文为[Lao Zhang typed the code online]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140737237136.html