2016-10-24 20 views
1

我想使用不同類型(淺色,黑色,半粗體)的Google字體。如何使用不同種類的Google字體類型?

這是鏈接,谷歌字體:https://fonts.googleapis.com/css?family=Exo+2:300,400,600,900

常規工作正常,font-family: 'Exo 2';但我不知道我該如何使用光,黑色的。我已經嘗試了Exo 2 Black/Light,但這似乎並不奏效。

我也讀過文檔,但那也沒有答案。

+1

沒有光和黑色字體。所有你能做的就是設置字體重量 –

回答

4

您首先必須在文檔的頭部加載字體,並且在CSS中將字體與正確的font-weight結合使用。

PS:您的字體網址中有一個錯字。

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

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

您需要在css中使用font-weight屬性,並使用正確的字體權重數值表示。

在你的情況,你可以在URL查看可用不同的權重: https://fonts.googleapis.com/css?family=Exo+2:300,400,600,900

的300400600900對應的字體粗細。

  • 300 - 光
  • 400 - 定期(所以沒有必要宣佈它)
  • 600 - 大膽
  • 900 - 黑色

你的情況應該重量輕,font-weight: 900會是黑色的。

相關問題