我想使用Lato LIGHT字体并将其下载到我的字体文件夹中:fonts/Lato-Light.ttf
这是我的CSS文件:
@font-face {
font-family:'LatoLightFont';
src: url(../fonts/Lato-Light.ttf) format('ttf')
}
body {
font-family: 'LatoLightFont', "Courier New";
font-size: 16px;
line-height: 32px;
font-weight: 200;
}
p {
font-family: 'LatoLightFont', "Courier New";
}
h1, h2, h3, h4, h5, h6 {
font-family: 'LatoLightFont', "Courier New";
}
但是我的网站的字体是Courier New而不是Lato-Light。怎么了?
问题是我想使用 Lato,但 LIGHT 版本。我以为我可以通过使用字体样式来使用 LIGHT 版本:Light,但这也不起作用。
问题似乎是format()
函数/属性中的错误,您有:
@font-face {
font-family:'LatoLightFont';
src: url(../fonts/Lato-Light.ttf) format('ttf')
}
而它应该是,从参考 Mozilla 托管的文档:
@font-face {
font-family:'LatoLightFont';
src: url(../fonts/Lato-Light.ttf) format('opentype')
}
引用:
@font-face
.