我想使用不同类型(浅色,黑色,半粗体)的Google字体。
这是Google字体的链接:https : //fonts.googleapis.com/css?family=Exo+2 : 300,400,600,900
常规工作正常,font-family: 'Exo 2';但是我想知道如何使用浅色,黑色的。我尝试了Exo 2 Black / Light,但似乎没有用。
我也阅读了文档,但是也没有答案。
首先,您必须在文档的头部加载字体,然后font-weight在CSS 中将字体与右侧一起使用。
PS:您的字体URL中有一些错字。
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Website</title>
<link href="https://fonts.googleapis.com/css?family=Exo+2:300,400,600,900" rel="stylesheet">
<link href="path/to/styles.css" rel="stylesheet">
</head>
<body>
…
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
styles.css
.light {
font-family: 'Exo 2';
font-weight: 300;
}
.normal {
font-family: 'Exo 2';
font-weight: 400;
}
.semi-bold {
font-family: 'Exo 2';
font-weight: 600;
}
.black {
font-family: 'Exo 2';
font-weight: 900;
}
Run Code Online (Sandbox Code Playgroud)