声明的字体粗细但不能调用字体粗细

时间:2020-09-05 11:20:29

标签: html css font-face

我添加了字体并声明了字体粗细:

@font-face {
font-family: 'Gotham-Medium';
font-weight: 700; 
src: url("fonts/Gotham-Medium-Regular.woff");
}

但是font-weight不起作用-因此下面的代码不调用Medium字体(它称为粗体字体)。我究竟做错了什么?顺便说一句,我不必添加常规和粗体的gotham字体文件,无论如何我已经可以访问它。

.active, .accordion:hover {
font-weight: 700;
}

下面的代码正确调用了中等字体,但我希望使用'font-weight'来调用中等字体。

.active, .accordion:hover {
 font-family: 'Gotham-Medium'; 
 }

1 个答案:

答案 0 :(得分:0)

您不能使用字体粗细来调用字体。如果要使用字体,则需要同时使用两者。

.active, .accordion:hover {
     font-family: 'Gotham-Medium';
     font-weight: 700;
 }

编辑:两种字体都在单独的文件中吗?如果是这样,您应该可以像这样使用它们。

@font-face {
    font-family: 'Gotham';
    font-weight: 400; 
    src: url("fonts/Gotham-Medium-Regular.woff");
}


@font-face {
    font-family: 'Gotham';
    font-weight: 700; 
    src: url("fonts/Gotham-Bold-Regular.woff");
}

.active, .accordion {
    font-family: 'Gotham'
    font-weight: 400;
}

.active, .accordion:hover {
    font-weight: 700;
}