css rem 大小問題

clipboard.png

clipboard.png

clipboard.png

同樣是4.4rem,爲什麽一個是57px,一個是70px,可能是什麽原因

阅读 2.7k
2 个回答

rem
This unit represents the font-size of the root element (e.g. the
font-size of the <html> element). When used on the font-size on this
root element, it represents its initial value.

也就是说,rem的大小取决于给html元素设置的字体的大小。

在使用“em”作单位时,一定需要知道其父元素的设置,因为“em”就是一个相对值,而且是一个相对于父元素的值,其真正的计算公式是:

1 ÷ 父元素的font-size × 需要转换的像素值 = em值

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题