@font-face 在本地工作,但在实时网站上不起作用
我有一个正在生产的网站,它使用 @font-face 来渲染字体,这在本地环境中工作正常,但在上传到实时网站时失败。
链接到字体文件的 CSS 文件位于根目录中,并使用以下代码:
@font-face {
font-family: 'ColaborateLightRegular';
src: url('css/fonts/ColabLig-webfont.eot');
src: url('css/fonts/ColabLig-webfont.eot?#iefix') format('embedded-opentype'),
url('css/fonts/ColabLig-webfont.woff') format('woff'),
url('css/fonts/ColabLig-webfont.ttf') format('truetype'),
url('css/fonts/ColabLig-webfont.svg#webfontR2xcGGVv') format('svg');
font-weight: normal;
font-style: normal;
}
字体位于 /css/fonts/ 目录中。我尝试将以下内容添加到 .htaccess 文件中以尝试解决问题,但仍然无济于事:
<FilesMatch "\.(ttf|otf|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
我真的没有主意了!我只是觉得很奇怪,当我使用 XAMPP 查看时,跨浏览器没有任何问题,但是当我尝试在我的服务器(Apache)上查看它时,它在任何浏览器上都无法工作。
I have a website in production which uses @font-face to render fonts, and this works fine in a local environment but fails when uploaded to the live website.
The CSS file which links to the font files is in the root directory, and uses the following code:
@font-face {
font-family: 'ColaborateLightRegular';
src: url('css/fonts/ColabLig-webfont.eot');
src: url('css/fonts/ColabLig-webfont.eot?#iefix') format('embedded-opentype'),
url('css/fonts/ColabLig-webfont.woff') format('woff'),
url('css/fonts/ColabLig-webfont.ttf') format('truetype'),
url('css/fonts/ColabLig-webfont.svg#webfontR2xcGGVv') format('svg');
font-weight: normal;
font-style: normal;
}
The font is in the /css/fonts/ directory. I have tried adding the following to an .htaccess file to try fix the issue but still to no avail:
<FilesMatch "\.(ttf|otf|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
I'm out of ideas really! I just find it very strange how I have no problems across browsers when viewing with XAMPP, but when I try and view it on my server (which is Apache) it wont work on any browser.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查文件夹上的 CHMOD 设置并确保服务器不会向您发送 403
Check your CHMOD settings on the folders and make sure the server's not sending you a 403 back