问题描述
因此,通过text=
,我们可以指定要加载的字形。
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@900&text=HEADER&display=swap" rel="stylesheet">
此外,我们可以同时加载多个权重:
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;700&display=swap" rel="stylesheet">
我不知道(在任何地方都找不到答案)的是如何组合这些行。那就是:我需要整套的权重400和700,但是只需要特定的字形就可以实现权重900。
我尝试了几种组合,但是它们不起作用。当我简单地拨打两个电话时,我仅获得第一行的权重。当我将它们组合在一起进行一次调用时,我仅获得所有权重的指定字形。
不起作用的示例:
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;700;900&text=HEADER&display=swap" rel="stylesheet">
或
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;700&family=Nunito+Sans:wght@900&text=HEADER&display=swap" rel="stylesheet">
谢谢!
解决方法
在这里工作正常:
.nunito { font-family: Nunito Sans }
.w4 { font-weight: 400 }
.w7 { font-weight: 700 }
.w9 { font-weight: 900 }
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@900&text=HEADR&display=swap" rel="stylesheet">
<div class="nunito">
<span class="w4">NOT THE HEADER full set</span><br>
<span class="w7">NOT THE HEADER full set</span><br>
<span class="w9">NOT THE HEADER full set</span>
</div>