【发布时间】:2019-06-12 12:49:56
【问题描述】:
在我的代码中,我使用
{
font-size: 2.5rem;
font-weight: 100;
}
设置字体,但是当我将其切换为字体简写时,就像这样{font: 100 2.5rem}
它似乎不起作用,我的字体样式更改为默认样式。
pic 看来我已经遵循了字体的简写规则,有人可以帮忙吗?
【问题讨论】:
标签: html css frontend font-size shorthand
在我的代码中,我使用
{
font-size: 2.5rem;
font-weight: 100;
}
设置字体,但是当我将其切换为字体简写时,就像这样{font: 100 2.5rem}
它似乎不起作用,我的字体样式更改为默认样式。
pic 看来我已经遵循了字体的简写规则,有人可以帮忙吗?
【问题讨论】:
标签: html css frontend font-size shorthand
font 速记属性需要指定 font-size 和 font-family。 line-height 和其他 font-* 属性是可选的。
【讨论】:
字体粗细定义了由细到粗的字符。100-400与普通相同,700-900与粗体相同。给出 Font-weight 后,您需要给出 font-family 属性。如果您不想使用任何字体系列,则只需将字体系列设置为无。这对我有用。
<!DOCTYPE html>
<html>
<head>
<style>
p.a {
font: 100 2.5rem none;
}
p.b {
font: 400 2.5rem none;
}
p.c {
font: 700 2.5rem arial, sans-serif;
}
p.d {
font: 800 2.5rem Georgia, serif;
}
p.e {
font: 900 2.5rem normal;
}
</style>
</head>
<body>
<h1>The font Property</h1>
<p class="a">This is a paragraph. The font size is set to 10 pixels.</p>
<p class="b">This is a paragraph. The font size is set to 10 pixels.</p>
<p class="c">This is a paragraph. The font size is set to 10 pixels.</p>
<p class="d">This is a paragraph. The font size is set to 10 pixels.</p>
<p class="e">This is a paragraph. The font size is set to 10 pixels.</p>
</body>
</html>
【讨论】: