【问题标题】:font awesome icon is not appearing in IE 11, but showing in other browsers字体真棒图标未出现在 IE 11 中,但显示在其他浏览器中
【发布时间】:2015-09-26 06:56:59
【问题描述】:

我是字体真棒图标的新手。我有一个页面,其中有一个过滤器,用户可以在其中搜索数据。我在搜索链接之前添加了很棒的字体图标(如下图所示),我可以在除 IE 11 之外的所有浏览器中看到这个图标。有趣的是我在其他页面中也有这个图标,我可以在 IE 中看到它11,但我仅在此(如下图所示)页面上看不到此图标。

这是 IE 11 的屏幕截图:

这是来自 chrome 的截图:

谁能帮我解决这个问题?

【问题讨论】:

    标签: internet-explorer-11 font-awesome


    【解决方案1】:

    两种解决方案中的任何一种都适合我

    1. 检查以下是否都提到 FontAwesome.otf fontawesome-webfont.eot fontawesome-webfont.svg fontawesome-webfont.ttf fontawesome-webfont.woff fontawesome-webfont.woff2
    2. 我删除了版本参数,例如。 ?v4.7.0 在 CSS 中字体的每个 src 中,它现在可以在我的 IE 11 中使用。

    【讨论】:

      【解决方案2】:

      对于 Internet Explorer 11,您可以像这样更改您的 CSS:

      nb-icon.menu-icon { 
                        visibility: hidden; 
                        } 
      nb-icon.menu-icon::before{ 
                        visibility: visible; 
                        }
      

      【讨论】:

        【解决方案3】:

        我遇到了同样的问题。我的技术栈是 Spring boot 2.0 和 Angular 8。 仅当您尝试在 IE 11 上通过 HTTPS 刷新页面时才会出现此问题。

        问题是,浏览器(IE 11)需要 Cache-Control max-age。您需要为静态资源设置此标头。 要解决此问题,请在 application.property 文件中设置以下属性。

        spring.resources.cache.cachecontrol.max-age=14400
        

        【讨论】:

          【解决方案4】:

          我们最近遇到了从我们的 Rails 应用程序中提供 Font Awesome 字体文件的问题。令人困惑的是,我们没有传递 PragmaCache-control 响应标头 - 所以这篇文章中之前的答案有点令人困惑。

          总结 - 这个问题是由这两个条件引起的:

          1. 请求是通过 HTTPS 连接从 font-face 发起的(对于在本地重现此错误至关重要)。
          2. Pragma 标头的值为 no-cache 或者在我们的例子中,我们提供所有 gzip 文件,Vary 标头传递的值不是Accept-Encoding

          我们通过在 Rack::CORS 配置中添加以下内容来解决此问题:

          config.middleware.insert_before 0, Rack::Cors do
                allow do
                  origins '*'
          
                  # Setting Vary to Accept-Encoding required or IE11 fonts will not load from local cache
                  resource('*.eot',
                           headers: :any,
                           credentials: false,
                           methods: [:get],
                           vary: ['Accept-Encoding'])
                end
              end
          

          【讨论】:

            【解决方案5】:
            【解决方案6】:

            或者,您的 Internet Explorer 设置可能会阻止浏览器下载字体。我们的其中一台受到严格保护的服务器就是这种情况。

            试试这些步骤:

            1. 打开 Internet Explorer
            2. 转到 Internet 选项
            3. 在安全选项卡下,单击自定义级别...
            4. 向下滚动到下载并确保字体下载已启用

            【讨论】:

              【解决方案7】:

              IE 遇到@font-faces 与 HTTP-Header Pragma=no-cache 一起传送的问题。你可以看到它记录在问题跟踪器here

              很遗憾,该问题被标记为不可解决,但有一些解决方法。对我有用的是使用 servlet 过滤器来避免设置 Pragma 标头。

              其他不适合我的解决方案:

              Font-awesome disappears after refresh for all ie browsers ie11,ie10,ie9

              Font awesome icons becomes invisible in IE after refresh

              【讨论】:

              【解决方案8】:

              我在使用 Font Awesome 4.7 和 IE 11 时遇到了同样的问题。我通过在 <head> 部分添加以下元信息来修复它:

              <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
              

              【讨论】:

                【解决方案9】:

                就我而言,它是损坏的 .eot 字体文件。我生成了一个新的(+ 新的 .css 样式),它解决了这个问题。试试吧。

                【讨论】:

                  【解决方案10】:

                  我遇到了同样的问题,我通过在&lt;head&gt;:
                  &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;

                  中添加这个元标记作为 FIRST 标记来解决它

                  另外,根据official documentation,检查以下内容:

                  对于 Internet Explorer:您不会在缓存控制标头中使用 no-store 选项提供文件(参考:#6454);
                  对于 Internet Explorer 和 HTTPS strong>:您不会在 Pragma 标头中使用 no-cache 选项提供文件。

                  【讨论】:

                    【解决方案11】:

                    我遇到了同样的问题,我只是在标签中添加了以下链接,它就起作用了。

                    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
                    

                    希望这会有所帮助!

                    【讨论】:

                      【解决方案12】:

                      如果您将 Spring MVC 与 Spring Security 一起使用,Spring Security 会自动不添加缓存标头,因此会导致 font-awesome 在 IE11 上中断。

                      (https://docs.spring.io/spring-security/site/docs/current/reference/html/headers.html#headers-cache-control)

                      我通过在我的WebMvcConfiguration 中添加一个ResourceHandler 解决了这个问题,该字体被配置为允许浏览器缓存字体。

                      public class WebMvcConfiguration extends WebMvcConfigurerAdapter
                      {
                          @Override
                          public void addResourceHandlers( ResourceHandlerRegistry registry )
                          {
                              registry.addResourceHandler("/assets/vendor/font-awesome/fonts/**")
                                  .addResourceLocations("/assets/vendor/font-awesome/fonts/")
                                  .setCachePeriod(31556926);        
                          }
                      }
                      

                      【讨论】:

                        【解决方案13】:

                        如果 apache 服务器正在提供字体文件,请将以下条目添加到 httpd.conf 或 .htaccess 中。

                        要为字体文件设置正确的 mime 类型,请将以下行添加到配置中:

                         AddType application/vnd.ms-fontobject .eot
                         AddType font/truetype .ttf
                         AddType font/opentype .otf
                         AddType font/opentype .woff
                         AddType image/svg+xml .svg .svgz
                        

                        为了更新字体文件头,这个修复完美地在 IE 浏览器中呈现字体图标。

                        <LocationMatch "\.(eot|otf|woff|ttf)$">
                           Header unset Cache-Control
                           Header unset no-store
                        </LocationMatch >
                        

                        【讨论】:

                          【解决方案14】:

                          我对字体真棒有同样的问题。我在我的 .net 应用程序中添加了一个自定义 httpmodule。

                          public class MyHttpModule : IHttpModule
                              {
                                  public void Dispose()
                                  {
                                  }
                                  public void Init(HttpApplication context)
                                  {
                                      context.EndRequest += new EventHandler(Context_EndRequest);
                                  }
                                  protected void Context_EndRequest(object sender, EventArgs e)
                                  {
                                      HttpResponse response = HttpContext.Current.Response;
                                      if (string.Compare(HttpContext.Current.Request.Browser.Browser, "InternetExplorer", StringComparison.InvariantCultureIgnoreCase) == 0)
                                      {
                                          response.Headers.Set("Pragma", "none");
                                      }
                                  }
                              }
                          

                          并在 web.config 中注册了模块。

                          <system.webserver>
                              <modules>
                                    <add type="MyHttpModule, Culture=neutral" name="MyHttpModule"/>
                              </modules>
                          </system.webserver>
                          

                          它解决了这个问题。

                          【讨论】:

                          • System.Web.HttpException HResult=0x80004005 Message=服务器无法在 HTTP 标头发送后附加标头。 Source=MyModule StackTrace: 在 MyModule.MyHttpModule.Context_EndRequest(Object sender, EventArgs e) 在 T:\Websites\MyModule\MyModule\MyModule.cs:line 27
                          【解决方案15】:

                          从 IE 控制台尝试运行以下脚本

                          $('head').append('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" type="text/css" />');
                          

                          如果可行,请尝试将其导入 CDN,而不是将其存储在本地。

                          【讨论】:

                            【解决方案16】:

                            这修复了我在 IIS 中的字体图标:将 web.config 添加到您的字体目录,其中包含以下内容:

                            <?xml version="1.0" encoding="UTF-8"?>
                            <configuration>
                                <system.webServer>
                                    <httpProtocol>
                                        <customHeaders>
                                            <add name="Pragma" value="none" /> 
                                        </customHeaders>
                                    </httpProtocol>
                                </system.webServer>
                            </configuration>
                            

                            【讨论】:

                            • 好的。会试一试。谢谢!
                            • 很好的解决方案,在我们的应用程序中,出于安全原因,我们需要 no-store 和 no-cache 标头(通过根项目中的 web.config 添加)。然后在字体文件夹中,我们使用以下说明添加了新的 web.config: 解决了我们的问题。
                            • 嗨@ChrisGheen你能引用你的来源吗?我还没有找到一个参考,其中“none”是“pragma”的有效值。请参阅:w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.32 谢谢
                            猜你喜欢
                            • 1970-01-01
                            • 2016-08-17
                            • 2014-05-30
                            • 1970-01-01
                            • 1970-01-01
                            • 1970-01-01
                            • 2019-09-13
                            • 1970-01-01
                            • 2017-09-06
                            相关资源
                            最近更新 更多