选择 Google 字体的样式

Selecting style in Google fonts

如何使用 google 字体在 css 中应用两种不同的 montserrat 样式(一个部分为粗体,另一个部分为常规)?使用 google 字体中提供的 link 我只能使用一个

我假设您已经这样做了,但是,首先是嵌入字体。您可以通过在 HTML 上使用 link 标签来执行此操作,如下所示:

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap" rel="stylesheet">

或者在 CSS 上使用导入,像这样:

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap');

之后,在您的 CSS 上,您需要使用正确的字体系列,如下所示:

font-family: 'Montserrat', sans-serif;

然后指定字体粗细,像这样:

font-weight: 700;