Is sizing fonts using “em” still relevant?

后端 未结 8 1766
-上瘾入骨i
-上瘾入骨i 2020-12-22 14:51

Those of you who use em when sizing fonts will know that they can be a headache when dealing with nested elements, and having to make the px -> em

相关标签:
8条回答
  • 2020-12-22 15:50

    Although allowed, I've always felt it's a little nonsensical to size your fonts using em. When used for font sizing, it's a relative measure, and I think it just adds confusion to your CSS. If you really mean to give your font a size relative to it's parent font size, use percents. (font-size: 0.8em is equivalent to font-size: 80%, but the percent is more sensical.)

    Otherwise use one of the absolute units. Browsers handle and scale them fine now.

    0 讨论(0)
  • 2020-12-22 15:53

    I never use pixel sizes for fonts in any program (except Photoshop I suppose, since it just had it in pixels by default). I've always used point size (such as in Word) and have since moved to scaling relatively in CSS with em. I set the body font-size then scale using em.

    Maybe I'm just used to knowing how big point sizes are on screen and in print. I can never guess the size of a pixel font height so I don't use it.

    0 讨论(0)
提交回复
热议问题