想要使用lato light - 字体重量不变

use*_*916 2 css fonts

想要使用Lato灯..以下不起作用:

body {
    font-family: "lato"; 
    background-color: white;
    font-weight: 300; 
}
Run Code Online (Sandbox Code Playgroud)

可能有什么不对?

And*_*hiu 9

为了能够使用特定的font-weight你首先必须加载它.

实用解决方案

用以下内容替换<link>导入Lato的标记:

<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700" rel="stylesheet">
Run Code Online (Sandbox Code Playgroud)

请注意family:Lato:300,400,700部分.更改它以满足font-weight您的项目需求.如果您使用拉丁语扩展子集,您还需要通过更改链接来添加它

<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700&subset=latin-ext" rel="stylesheet">
Run Code Online (Sandbox Code Playgroud)

您可以深入挖掘并提供服务器中的字体文件,但总体而言,不建议在页面速度方面.