“字体家族”之间的区别和字体家族? [英] Difference between "font-family" and font-family?
问题描述
我刚发现我的Chrome浏览器会处理 font-family:sans-serif
和 font-family:sans-serif
不同(它会选择不同的字体)。任何人都可以解释这是如何运作我无法在规范中找到任何线索。 从相同的规格:
如果给定一个标识符序列作为字体系列名称,
计算值是通过连接序列中的所有
标识符转换为字符串的名称为避免转义错误,建议引用含有空格,数字或标点符号的字体系列名称
字符除了连字符外: 作为一个字符串,而后者被认为是通用的。I just discovered that my Chrome will treat
font-family: "sans-serif"
andfont-family: sans-serif
differently (it will choose different fonts). Can anyone explain how this works?I can't find any clues in the specs.[edit: ...as I obviously didn't read them very carefully.]解决方案From the same specs:
If a sequence of identifiers is given as a font family name, the computed value is the name converted to a string by joining all the identifiers in the sequence by single spaces.
To avoid mistakes in escaping, it is recommended to quote font family names that contain white space, digits, or punctuation characters other than hyphens:
So when you are writing "san-serif" then it is a specific font and is considered as a string whereas the latter is considered as generic.
这篇关于“字体家族”之间的区别和字体家族?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!