Css @字体面显示我导入的.woff和.ttf字体的404错误
我使用font face导入我的自定义web字体,但字体未加载到浏览器中控制台中显示404 file not found错误,但我的字体位于同一目录中,字体名称与我在Css @字体面显示我导入的.woff和.ttf字体的404错误,css,apache,.htaccess,fonts,webfonts,Css,Apache,.htaccess,Fonts,Webfonts,我使用font face导入我的自定义web字体,但字体未加载到浏览器中控制台中显示404 file not found错误,但我的字体位于同一目录中,字体名称与我在font face @font-face { font-family: 'Proxima Nova'; src: url("../fonts/proximanova-light-webfont.eot"); src: url("../fonts/proximanova-light-webfont.eot?#iefix")
font face
@font-face {
font-family: 'Proxima Nova';
src: url("../fonts/proximanova-light-webfont.eot");
src: url("../fonts/proximanova-light-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/proximanova-light-webfont.woff") format("woff"), url("../fonts/proximanova-light-webfont.ttf") format("truetype"), url("../fonts/proximanova-light-webfont.svg#ProximaNovaLight") format("svg");
font-weight: 100;
font-style: normal;
}
@font-face {
font-family: 'Proxima Nova';
src: url("../fonts/proximanova-reg-webfont.eot");
src: url("../fonts/proximanova-reg-webfont.eot?#iefix") format("embedded-opentype"), url("../fonts/proximanova-reg-webfont.woff") format("woff"), url("../fonts/proximanova-reg-webfont.ttf") format("truetype"), url("../fonts/proximanova-reg-webfont.svg#ProximaNovaRegular") format("svg");
font-weight: normal;
font-style: normal;
}
此外,我还尝试添加这些行。httaccess它不起作用,我也浏览了,所以没有人有正确的解决方案,伙计们,请帮助我
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-opentype .otf
AddType image/svg+xml .svg
AddType application/x-font-ttf .ttf
AddType application/font-woff .wof
您的网站是否在windows服务器上运行?如果是这样,请尝试为字体扩展添加正确的Mime类型。这可能是以下内容的副本:
顺便说一句,你的问题中“AddType”代码块的最后一句有一个输入错误。它的.woff(两个f)。试试这个:
@font-face {
font-family: 'Proxima Nova';
src: url("./fontsproximanova-light-webfont.eot");
src: url("./fontsproximanova-light-webfont.eot?#iefix") format("embedded-opentype"), url("./fontsproximanova-light-webfont.woff") format("woff"), url("./fontsproximanova-light-webfont.ttf") format("truetype"), url("./fontsproximanova-light-webfont.svg#ProximaNovaLight") format("svg");
font-weight: 100;
font-style: normal;
}
@font-face {
font-family: 'Proxima Nova';
src: url("./fontsproximanova-reg-webfont.eot");
src: url("./fontsproximanova-reg-webfont.eot?#iefix") format("embedded-opentype"), url("./fontsproximanova-reg-webfont.woff") format("woff"), url("./fontsproximanova-reg-webfont.ttf") format("truetype"), url("./fontsproximanova-reg-webfont.svg#ProximaNovaRegular") format("svg");
font-weight: normal;
font-style: normal;
}
AddType
指令用于让服务器发送具有正确MIME类型标题的字体文件(以便浏览器知道如何解释它们),对于404错误没有帮助。404向我指出CSS中的url
s不正确
让我知道它是否有效。我想补充一点,因为这个问题困扰着我,Apache有/icons/的别名,作为/etc/httpd/conf.d/autoindex.conf的一部分。字体是否相对于css文件放置?@Pete yea我在css中提到的同一目录中有字体,即使在我键入完整url时下载,但有时不查看浏览器中的“网络”选项卡并找出它尝试的路径负载然后修复你的代码。@h2ooooooo它显示了正确的路径,在那里我有可能重复的Nope,我正在运行centos