我无法使用@ font-face将此自定义字体添加到CSS中。我尝试了使用其他有效字体的代码,但无法使用该字体。

@font-face{
    font-family:"Megatron";
    src:url{"fonts/Megatron.otf"};
}
h1{
    font-family: Megatron;
}


<h1>Enigma</h1>


这是字体的链接
https://blogfonts.com/megatron.font

最佳答案

该字体(以及您要使用的其他字体)必须位于项目文件夹的fonts文件夹中。
尝试以下代码后:

@font-face{
    font-family:"Megatron";
    src:url("/fonts/Megatron.otf") format("opentype");
}
h1{
    font-family: Megatron;
}


附言您的字体链接不起作用:(

关于html - 无法在CSS中使用此自定义字体,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59679012/

10-09 17:49
查看更多