Css 404 IE加载字体时出错
我这样称呼我的字体:Css 404 IE加载字体时出错,css,internet-explorer,http-status-code-404,font-face,Css,Internet Explorer,Http Status Code 404,Font Face,我这样称呼我的字体: @font-face { font-family: 'dinar'; src: url('../fonts/dinarm.eot?#'), local('?'), local('Mj_Dinar Two Medium'), url('../fonts/dinarm.woff') format('woff'), url('../fonts/dinarm.ttf') format('truetype'),
@font-face {
font-family: 'dinar';
src: url('../fonts/dinarm.eot?#'),
local('?'),
local('Mj_Dinar Two Medium'),
url('../fonts/dinarm.woff') format('woff'),
url('../fonts/dinarm.ttf') format('truetype'),
url('../fonts/dinarm.svg') format('svg');
font-weight: normal;
font-style: normal
}
@font-face {
font-family: 'font-bmi';
src: url('../fonts/font-bmi/font-bmi.eot');
src: url('../fonts/font-bmi/font-bmi.eot') format('eot'),
url('../fonts/font-bmi/font-bmi.woff') format('woff'),
url('../fonts/font-bmi/font-bmi.ttf') format('truetype');
font-weight: normal;
font-style: normal
}
每次使用Internet Explorer的用户尝试访问该网站时,我都会在web主机使用日志中看到大量404错误,最终该用户被我的安全插件禁止。下面是使用日志的一个示例:
80.00.000.146 - - [05/Apr/2017:00:46:10 +0430]
"GET /wp-content/themes/fonts/font-bmi/font-bmi.eot)%20format(%22eot%22),
%20url(../fonts/font-bmi/font-bmi.woff)%20format(%22woff%22),
%20url(../fonts/font-bmi/font-bmi.ttf)%20format(%22truetype%22 HTTP/1.1" 404 4058
"http://www.21tech.ir/some-page/" "Mozilla/4.0
(compatible; MSIE 8.0; Windows NT 5.1; --some other information--)"
我知道它写了Mozilla/4.0
,但实际上我已经测试过它了
问题是什么?如何解决或避免?原因是旧版本的IE无法正确解释第二个
@font-face
声明中的第二个src
属性。解决方案是在该属性的.eot URL的末尾附加一个问号(?),诱使IE认为下面的所有内容都是查询字符串:
@font-face {
font-family:"font-bmi";
src:url("../fonts/font-bmi/font-bmi.eot?#iefix") format("embedded-opentype"),
url("../fonts/font-bmi/font-bmi.woff2") format("woff2"),
url("../fonts/font-bmi/font-bmi.woff") format("woff"),
url("../fonts/font-bmi/font-bmi.ttf") format("truetype");
font-weight:normal;
font-style:normal
}
您在第一次@font-face
声明中尝试了一些不同的“黑客”来解决这个问题,但是,尽管您成功地阻止了IE报告404,但上述解决方案更干净,并且不会影响CSS的可读性
要进一步阅读,请参阅Paul Irish 2009年的“”文章。路径应该与css文件本身相关,而不是与调用css的页面相关。这是正确的路径吗?@iguypouf是的,这只发生在IE上。事实上,我看到了我的每种字体的错误,第一种不正确,我只是粘贴了部分错误。我尝试了你的建议,但没有成功。你回答的第一个环节,成功了。谢谢。您所做的更改是什么?它与我的解决方案有何区别?使用了以下内容:
@font-face{font-family:'font-bmi';src:url('../font/font-bmi/font-bmi.eot');src:url('../font/font-bmi.eot?#iefix')格式('embedded-opentype')、url('../font/font-bmi/font-bmi/font-bmi.woff')格式('woff')、url(../font-bmi/font-bmi.ttf'))格式('truetype');字体重量:正常;字体样式:正常}
Hmm。。。您不应该需要第一个src
属性,您可以尝试删除它,看看它是否仍然有效吗?