Web Fonts don't work in firefox on local, but do on server

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 04:24:57

问题


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');

}


回答1:


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.



来源:https://stackoverflow.com/questions/14088263/web-fonts-dont-work-in-firefox-on-local-but-do-on-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!