【问题标题】:Selecting style in Google fonts在 Google 字体中选择样式
【发布时间】:2021-09-25 10:35:28
【问题描述】:

如何使用谷歌字体在 css 中应用蒙特塞拉特的两种不同样式(一个部分为粗体,另一部分为常规)?使用谷歌字体中提供的链接,我只能使用一个

【问题讨论】:

  • google fonts中提供的链接我只能使用一种,这是完全错误的,如果您选择并链接多种字体类型,您可以使用多种

标签: html css google-fonts


【解决方案1】:

我假设您已经这样做了,但步骤是首先嵌入字体。您可以通过在 HTML 上使用链接标签来做到这一点,如下所示:

<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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-22
    • 1970-01-01
    • 2012-11-18
    • 2014-09-19
    • 2017-05-04
    • 2014-04-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多