CSS字体声明问题
this:
font-family: Arial, helevetica;
和 this:
font: arial/ helvetica;
我都见过,但不太确定有什么区别?
whats the difference between this:
font-family: Arial, helevetica;
and this:
font: arial/ helvetica;
I've seen both but not really sure of the difference?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
斜杠 (
/
) 是拼写错误吗?因为我可以在font:
属性中成像的唯一斜杠是表示字体大小和行高的斜杠(例如16px/20px
)无论如何,
font:
是允许您一次设置多个字体属性的属性,而font-family
显然只允许您设置字体。使用font:
您还可以设置大小、粗体/斜体、行高和变体:与以下内容相同:
您也可以省略已设置的属性。对于大小、系列和粗体:
Is the slash (
/
) a typo? Because the only slash I can image in thefont:
property is the one denoting font-size and line-height (e.g.16px/20px
)Anyway,
font:
is the property that lets you set several font properties at once, whereasfont-family
obviously only lets you set the font face. Withfont:
you can also set size, bold/italic, line-height and variant:Is the same as:
You can omit properties that are already set, too. For just size, family and bold:
感谢您提出这个问题。
正如 @Stephan Muller 所说,斜杠可能只是试图表示字体大小和行高的拼写错误,但是有也可以是某些字体中的斜线,例如:
希望这有帮助!
Thanks for asking this question.
As @Stephan Muller said the slash could just be a typo trying to denote the font-size and line-height, however there can also be a slash in some fonts like these:
Hope this helps!
斜杠是用于同时设置字体大小和行高的简写。因此,您的简写语法是不正确的。
是斜杠的唯一正确用法。在此示例中,它将字体大小设置为 12px,行高设置为 14px,字体系列设置为 Arial、helvetica。
The slash is a shorthand used to set font size and line height at the same time. So, the syntax is of the shorthand you have is incorrect.
is the only correct usage of the slash. In this example it would set the font size to 12px, the line height to 14px and the font family to Arial, helvetica.