使用默认字体的字体家族

时间:2018-10-07 10:22:13

标签: html css fonts

我想使用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版本,但这也不起作用。

1 个答案:

答案 0 :(得分:1)

问题似乎是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')
}

参考文献:

相关问题