Font size in CSS - % or em?

后端 未结 8 1852
走了就别回头了
走了就别回头了 2020-11-28 02:24

When setting the size of fonts in CSS, should I be using a percent value (%) or em? Can you explain the advantage?

8条回答
  •  天涯浪人
    2020-11-28 02:32

    There's a really good article on web typography on A List Apart.

    Their conclusion:

    Sizing text and line-height in ems, with a percentage specified on the body (and an optional caveat for Safari 2), was shown to provide accurate, resizable text across all browsers in common use today. This is a technique you can put in your kit bag and use as a best practice for sizing text in CSS that satisfies both designers and readers.

提交回复
热议问题