我的字体 shorthand 不起作用,其中包括字体大小和字体粗细属性
My font shorthand doesn't work, which include font-size and font-weight properities
在我的代码中,我使用
{
font-size: 2.5rem;
font-weight: 100;
}
设置字体,但是当我将其切换为字体 shorthand 时,像这样 {font: 100 2.5rem}
它似乎不起作用,我的字体样式更改为默认。
pic
看来我已经遵循了字体的 shorthand 规则,有人可以帮忙吗?
Font-weight定义从细到粗的字符。100-400与普通字符相同,而700-900与粗体相同。在给出 Font-weight 之后你需要给出 font-family 属性。如果您不想使用任何 font-family,则只需将 font-family 设为 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>
font
shorthand属性需要指定font-size
和font-family
。 line-height
和其他 font-*
属性是可选的。
在我的代码中,我使用
{
font-size: 2.5rem;
font-weight: 100;
}
设置字体,但是当我将其切换为字体 shorthand 时,像这样 {font: 100 2.5rem}
它似乎不起作用,我的字体样式更改为默认。
pic 看来我已经遵循了字体的 shorthand 规则,有人可以帮忙吗?
Font-weight定义从细到粗的字符。100-400与普通字符相同,而700-900与粗体相同。在给出 Font-weight 之后你需要给出 font-family 属性。如果您不想使用任何 font-family,则只需将 font-family 设为 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>
font
shorthand属性需要指定font-size
和font-family
。 line-height
和其他 font-*
属性是可选的。