CSS: 100% font size - 100% of what?

前端 未结 9 680
梦毁少年i
梦毁少年i 2020-11-30 17:35

There are many articles and questions about percentage-sized vs other-sized fonts. However, I can not find out WHAT the reference of the percent-value is supposed to be. I u

9条回答
  •  抹茶落季
    2020-11-30 17:52

    As you showed convincingly, the font-size: 100%; will not render the same in all browsers. However, you will set your font face in your CSS file, so this will be the same (or a fallback) in all browsers.

    I believe font-size: 100%; can be very useful when combining it with em-based design. As this article shows, this will create a very flexible website.

    When is this useful? When your site needs to adapt to the visitors' wishes. Take for example an elderly man that puts his default font-size at 24 px. Or someone with a small screen with a large resolution that increases his default font-size because he otherwise has to squint. Most sites would break, but em-based sites are able to cope with these situations.

提交回复
热议问题