在我的项目中包含 google 字体

Including google font in my project

我在我的项目中加入了 Montserrat-Regular。但是它没有检测到,字体样式也没有改变。

在我的index.html:

我也包含了字体 URL。

<link href = "https://fonts.googleapis.com/css?family=Montserrat:400,700" rel='stylesheet' type='text/css'>

css:

 @import url(http://fonts.googleapis.com/css?family=Montserrat:400,700);

    @font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 400;
  src: local('Montserrat Regular'), local('Montserrat-Regular'), url(https://fonts.gstatic.com/s/montserrat/v10/SKK6Nusyv8QPNMtI4j9J2yEAvth_LlrfE80CYdSH47w.woff2) format('woff2');
  unicode-range: U+0102-0103, U+1EA0-1EF9, U+20AB;
}

在您的 CSS 文件中设置字体系列:

body { font-family: 'Montserrat', sans-serif; }

您只需将 link 放入您的 HTML 文件中:

<link href = "https://fonts.googleapis.com/css?family=Montserrat:400,700" rel='stylesheet' type='text/css'>

然后在 CSS 文件中的每个元素上使用它:

p { font-family: 'Montserrat'; }

检查此 fiddle 以获得更好的示例:https://jsfiddle.net/vf7q1gjy/1/