Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 为什么我的字体文件未下载或未加载?_Css_Http_Flask_Font Face - Fatal编程技术网

Css 为什么我的字体文件未下载或未加载?

Css 为什么我的字体文件未下载或未加载?,css,http,flask,font-face,Css,Http,Flask,Font Face,我在一个webfonts服务器上工作,我得到了api,可以用正确的mime类型输出css。它们也可以链接到页面 @font-face { font-family: 'Pagul'; src: url('http://localhost:5000/api/webfonts/static/Pagul.eot'); src: local('☺'), url('http://localhost:5000/api/webfonts/static/Pagul.woff') for

我在一个webfonts服务器上工作,我得到了api,可以用正确的mime类型输出css。它们也可以链接到页面

@font-face {
    font-family: 'Pagul';
    src: url('http://localhost:5000/api/webfonts/static/Pagul.eot');
    src: local('☺'), url('http://localhost:5000/api/webfonts/static/Pagul.woff')   format('woff'),
         url('http://localhost:5000/api/webfonts/static/Pagul.ttf') format('truetype'),
    font-weight: normal; 
    font-style: normal;
}
ttf、eot文件可以使用链接手动下载,出于某些原因,这些字体是 未通过浏览器加载我在这里做错了什么?字体文件没有正确的mimetype,这是问题所在吗

我也尝试了字体squirells语法,它不起作用。
PS:Css是动态生成并添加到头部的?

使用相对路径而不是绝对路径。例如,如果您的CSS位于site/CSS/style.CSS中,并且您的字体位于site/api/webfonts/static/目录中:

@font-face {
  font-family: Pagul;
  src: url('../api/webfonts/static/Pagul.eot');
  src: url('../api/webfonts/static/Pagul.woff') format('woff'),
     url('../api/webfonts/static/Pagul.ttf') format('truetype'),
  font-weight: normal; 
  font-style: normal;
}

或者,使用谷歌字体之类的服务,将他们的CSS链接到HTML上,或者直接导入CSS中

localhost
?开发者控制台中是否有任何控制台错误?无法做到这一点,我正在尝试制作类似google字体的东西,因此没有相对路径。啊,对不起,在这种情况下,我误解了你的问题