且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

rem与em在CSS中有何不同?

更新时间:2022-01-11 05:30:35

EM 相对于其父级字体大小

EMs are relative to their parent's font size

REM base font-size

REMs are relative to a base font-size

当中间容器更改字体大小时,这一点很重要。具有EM的子元素将受到影响,使用REM的子元素将不受影响。

This is important when intermediate containers change font sizes. Child elements with EMs will be affected, those using REMs will not.