如何在我的项目中使用“Lato”字体系列? [已关闭]

问题描述 投票:0回答:2

我在我的 .css 文件中使用了这样的样式,但它不起作用。我该怎么做才能让我的代码正常工作?

font-family: Lato, Helvetica, sans-serif;

链接:http://www.google.com/fonts/specimen/Lato

css font-family google-font-api
2个回答
97
投票

请将此代码放在头部

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

并在你的CSS中使用

font-family: 'Lato', sans-serif;
。例如:

h1 {
    font-family: 'Lato', sans-serif;
    font-weight: 400;
}

或者您也可以手动使用

.ttf
生成
fontSquiral

字体

并且可以尝试这个选项

    @font-face {
        font-family: "Lato";
        src: url('698242188-Lato-Bla.eot');
        src: url('698242188-Lato-Bla.eot?#iefix') format('embedded-opentype'),
        url('698242188-Lato-Bla.svg#Lato Black') format('svg'),
        url('698242188-Lato-Bla.woff') format('woff'),
        url('698242188-Lato-Bla.ttf') format('truetype');
        font-weight: normal;
        font-style: normal;
}

这样称呼

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

19
投票

here下载它并解压

LatoOFL.rar
然后转到TTF并打开这个font-face-generator单击
Choose File
选择您要使用的字体并单击生成然后下载它然后去
html 
文件打开它,你会看到这样的代码

@font-face {
        font-family: "Lato Black";
        src: url('698242188-Lato-Bla.eot');
        src: url('698242188-Lato-Bla.eot?#iefix') format('embedded-opentype'),
        url('698242188-Lato-Bla.svg#Lato Black') format('svg'),
        url('698242188-Lato-Bla.woff') format('woff'),
        url('698242188-Lato-Bla.ttf') format('truetype');
        font-weight: normal;
        font-style: normal;
}
body{
    font-family: "Lato Black";
    direction: ltr;
}

更改 src 代码并给出此字体目录所在的 url,现在您可以在您的网站上使用它...

如果您不想下载它,请使用此

<link type='text/css' href='http://fonts.googleapis.com/css?family=Lato:400,700' />
© www.soinside.com 2019 - 2024. All rights reserved.