【问题标题】:Font awesome not loading when using Python simple http server使用 Python 简单的 http 服务器时字体真棒不加载
【发布时间】:2014-05-16 01:38:19
【问题描述】:

我有一个简单的 html 文件,它使用很棒的字体显示大拇指向下图标。

<html>
  <script src="//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js"></script>
  <script>
    WebFont.load({
      custom: {
      families: ['FontAwesome'],
      urls : ['//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css']
    },
    fontloading: function(familyName, fvd) {},
    fontactive: function(familyName, fvd) {},
    fontinactive: function(familyName, fvd) {
    }});
  </script>
  <style type="text/css">
  html{
    background-color:black;
    color:green;
  }

  .thumb_down:before {
      content:"";
      font-family: FontAwesome;
      color: #ffffff;
  }

  </style>

  <body>
    <div class="thumb_down">I am here! </div>
  </body>
</html>  

工作小提琴here

现在,当我尝试使用 Python SimpleHTTPServer 在我的本地计算机上进行冲洗时,我的字体无法正确呈现。我得到这个输出

python -m SimpleHTTPServer

但是当我使用 php 服务器托管相同的服务器时,我得到了正确的结果,如小提琴所示。

php -S localhost:9000

知道这是否是 python 简单 HTTP 服务器的限制吗?

【问题讨论】:

    标签: python html font-awesome simplehttpserver


    【解决方案1】:

    这可能是编码。 PHP 可能正在添加标头,而 python 没有。如果你在&lt;html&gt; 标签之后添加它(就像 jsfiddle 一样),它可能会起作用

    <head>
        <meta charset="utf-8"> 
    </head>
    

    【讨论】:

    • 解决了!谢谢:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 2014-10-06
    • 2014-09-07
    • 1970-01-01
    • 1970-01-01
    • 2018-08-22
    • 2013-10-16
    相关资源
    最近更新 更多