gpt4 book ai didi

css - 当字体粗细不可用时,浏览器会做什么?

转载 作者:行者123 更新时间:2023-11-28 09:08:38 26 4
gpt4 key购买 nike

如果我加载带有 400 和 700 权重的 google 字体,但在我的 CSS 中我使用 font-weight:550; 浏览器会做什么?

最佳答案

根据 MDNW3.org :

If the exact weight given is unavailable, then the following heuristic is used to determine the weight actually rendered:

  • If a weight greater than 500 is given, the closest available darker weight is used (or, if there is none, the closest available lighter weight).
  • If a weight less than 400 is given, the closest available lighter weight is used (or, if there is none, the closest available darker weight).
  • If a weight of exactly 400 is given, then 500 is used. If 500 is not available, then the heuristic for font weights less than 500 is used.
  • If a weight of exactly 500 is given, then 400 is used. If 400 is not available, then the heuristic for font weights less than 400 is used.

This means that for fonts that provide only normal and bold, 100-500 are normal, and 600-900 are bold.

还有:

There is no guarantee that there will be a darker face for each of the 'font-weight' values; for example, some fonts may have only a normal and a bold face, while others may have eight face weights. There is no guarantee on how a UA will map font faces within a family to weight values. The only guarantee is that a face of a given value will be no less dark than the faces of lighter values.

关于css - 当字体粗细不可用时,浏览器会做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28482834/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com