CSS 上的字体无法加载



我试图在网页的CSS上使用谷歌字体,但它没有呈现所选的字体,而是显示了默认的无衬线字体。我可以对代码进行哪些更改?

h1 {
font-family: 'Montserrat-Black', sans-serif;
font-size: 3rem;
line-height: 1.5;
}
<link href="https://fonts.googleapis.com/css2?family=Montserrat" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Ubuntu" rel="stylesheet">
<h1>test</h1>

据我所知,您希望使用蒙塞拉特的黑色版本。以下是您的操作方法:

font-family: 'Montserrat', sans-serif;
font-weight: 400; /* This value changes from font to font. It's like a value of its boldness */
font-weight: bold; /* That's a way too */

第一种方法:对于使用此字体的黑色版本,您可以只导入黑色版本:

<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@900&display=swap" rel="stylesheet">

这样,对于使用黑色版本的Montserrat,您只需设置font-family: 'Montserrat', sans-serif;

第二种方法:你也可以导入所有版本,并给每个你想成为黑色版本的地方font-weight: 900;

如果您只需要黑色版本,请按第一种方式操作。否则第二。

最新更新