Web字体在本地不能在Firefox中使用,但在服务器上使用 [英] Web Fonts don't work in firefox on local, but do on server

查看:216
本文介绍了Web字体在本地不能在Firefox中使用,但在服务器上使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在本地开发一个网站,并使用符号的网页字体。当我在浏览器中查看文件时(例如file:///path/to/file.html),这些网页字体可以在Chrome浏览器中使用,但不能在Firefox中使用。但是,如果我上传该网站到我的服务器,并在Firefox中查看文件,它工作正常。任何想法,为什么会这样,我可以做什么来正确地在本地查看文件?

这是一个代码片段(所有路径都是有效的):

  @ font-face {
font-family:'WebSymbolsRegular';
$ b src:url('fonts / websymbols.eot?#iefix')format('embedded-opentype'),
url('fonts / websymbols.woff')format('woff ''),
url('fonts / websymbols.ttf')格式('truetype'),
url('fonts / websymbols.svg#WebSymbolsRegular')格式('svg'),
url('fonts / websymbols.eot');

}

解决方案这很可能是由于协议(文件而不是http)。你几乎总是想在本地服务器上测试一些东西,而不是在浏览器中从磁盘上打开一个页面。为Linux安装Apache,Nginx或Lighttpd;或IIS,IIS Express或Apache for Windows。然后,设置一个本地站点(即localhost:1234),指向站点的文件夹,然后运行你的页面。


I am developing a site locally and am using webfonts for symbols. When I just view the file in my browser (i.e. file:///path/to/file.html) the webfonts work in Chrome but not Firefox. However, if I upload the site to my server and view the file in Firefox, it works fine. Any idea why that would be and what I can do to view the file correctly locally?

Here is a code snippet (all paths are valid):

@font-face {
font-family: 'WebSymbolsRegular';

src: url('fonts/websymbols.eot?#iefix') format('embedded-opentype'),
     url('fonts/websymbols.woff') format('woff'),
     url('fonts/websymbols.ttf') format('truetype'),
     url('fonts/websymbols.svg#WebSymbolsRegular') format('svg'),
     url('fonts/websymbols.eot');

}

解决方案

It's most likely due to the protocol (file instead of http). You will almost always want to test things on a local server instead of just opening a page from disk in the browser. Install Apache, Nginx, or Lighttpd for Linux; or IIS, IIS Express, or Apache for Windows. Then, setup a local site (i.e., localhost:1234) that points to the folder with your site, and run your pages through that.

这篇关于Web字体在本地不能在Firefox中使用,但在服务器上使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆