在我的代码中,我使用
{
font-size: 2.5rem;
font-weight: 100;
}
设置字体,但是当我将其切换到字体速记时,就像这样{font: 100 2.5rem}
似乎不起作用,我的字体样式更改为默认值。
图片看来我已经遵循了字体的速记规则,有人可以帮忙吗?
font
速记属性需要指定font-size
和font-family
。line-height
和其他font-*
属性是可选的。
参考。
字体粗细定义从细字符到粗字符。100-400 与正常相同,700-900 与粗体相同。在赋予字体权重后,您需要赋予字体系列属性。如果您不想使用任何字体系列,则只需将字体系列设置为none即可。这对我有用。
<!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>