CSS字体声明问题

发布于 2024-10-06 06:56:23 字数 161 浏览 2 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜唯美灬不弃 2024-10-13 06:56:23

斜杠 (/) 是拼写错误吗?因为我可以在 font: 属性中成像的唯一斜杠是表示字体大小和行高的斜杠(例如 16px/20px

无论如何,font: 是允许您一次设置多个字体属性的属性,而 font-family 显然只允许您设置字体。使用 font: 您还可以设置大小、粗体/斜体、行高和变体:

font-weight: bold;
font-style: italic;
font-variant: small-caps;
font-size: 1em;
line-height: 1.5em;
font-family: verdana,sans-serif

与以下内容相同:

font: bold italic small-caps 1em/1.5em verdana,sans-serif;

您也可以省略已设置的属性。对于大小、系列和粗体:

font: bold 1em arial,verdana;

Is the slash (/) a typo? Because the only slash I can image in the font: 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, whereas font-family obviously only lets you set the font face. With font: you can also set size, bold/italic, line-height and variant:

font-weight: bold;
font-style: italic;
font-variant: small-caps;
font-size: 1em;
line-height: 1.5em;
font-family: verdana,sans-serif

Is the same as:

font: bold italic small-caps 1em/1.5em verdana,sans-serif;

You can omit properties that are already set, too. For just size, family and bold:

font: bold 1em arial,verdana;
清晰传感 2024-10-13 06:56:23

感谢您提出这个问题。

正如 @Stephan Muller 所说,斜杠可能只是试图表示字体大小和行高的拼写错误,但是有也可以是某些字体中的斜线,例如:

font-family: Copperplate / Copperplate Gothic Light, sans-serif;
font-family: Gill Sans / Gill Sans MT, sans-serif;

希望这有帮助!

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:

font-family: Copperplate / Copperplate Gothic Light, sans-serif;
font-family: Gill Sans / Gill Sans MT, sans-serif;

Hope this helps!

沒落の蓅哖 2024-10-13 06:56:23

斜杠是用于同时设置字体大小和行高的简写。因此,您的简写语法是不正确的。

font: 12px/14px Arial, helvetica;

是斜杠的唯一正确用法。在此示例中,它将字体大小设置为 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.

font: 12px/14px Arial, helvetica;

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文