Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.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
Php 自定义字体不起作用。Codeigniter_Php_Css_Codeigniter_Fonts - Fatal编程技术网

Php 自定义字体不起作用。Codeigniter

Php 自定义字体不起作用。Codeigniter,php,css,codeigniter,fonts,Php,Css,Codeigniter,Fonts,我想在我的应用程序中添加自定义字体,但它不起作用。 这里是字体所在的路径 @font-face { font-family: PF Din Text Cond Pro; src: url('/fonts/JtNLnKEa.ttf'); } 字体位于system/fonts/jtnlkea UPD @font-face { font-family: PF Din Text Cond Pro; src: url('http://con

我想在我的应用程序中添加自定义字体,但它不起作用。 这里是字体所在的路径

@font-face {    font-family: PF Din Text Cond Pro;
                 src: url('/fonts/JtNLnKEa.ttf'); }
字体位于
system/fonts/jtnlkea

UPD

@font-face {
    font-family: PF Din Text Cond Pro;
        src: url('http://contrast-energo.ru/fonts/JtNLnKEa.ttf');
}

body,html { 
  font-family: PF Din Text Cond Pro;
  height: 100%; 
  min-height: 100%; 
  margin-top: 0px;
}
如何修复


对不起,我的英语不好

请将您的字体添加到CodeIgniter可访问的目录中

@font-face {
  font-family: 'YourFontName'; /*a name to be used later*/
  src: url('http://domain.com/fonts/JtNLnKEa.ttf'); /*URL to font*/
}
并使用您的字体名称,如:

.classname {
  font-family: 'YourFontName';
}
编辑:


在根文件夹assets/css/font

中,应用程序结构应该如下所示

- application
- system
- assets
    - css
    - js
    - fonts
等等


那么您的访问url应该是
http://contrast-energo.ru/assets/fonts/JtNLnKEa.ttf

您的问题与CodeIgniter无关。您在CSS/HTML中遇到问题

您需要使用以下CSS代码将字体正确添加到HTML文档中:

@font-face {
    font-family: 'PF Din Text Cond Pro';
    src: url('fonts/PF-Din-Text-Cond-Pro.eot');
    src: url('fonts/PF-Din-Text-Cond-Pro.woff') format('woff'), 
         url('fonts/PF-Din-Text-Cond-Pro.ttf') format('truetype'), 
         url('fonts/PF-Din-Text-Cond-Pro.svg') format('svg');
    font-weight: normal;
    font-style: normal;
}
自定义字体将显示在所有浏览器上

如果要将字体指定给
主体
元素,可以使用以下选项:

body {font-family:'PF Din Text Cond Pro', Arial, sans-serif;}
您需要在单引号或双引号之间添加字体名称,因为它是一种自定义字体

如果只有“.otf”或“.ttf”字体文件,则需要将此文件转换为其他格式

是最好的免费字体转换器。

试试这个: 字体名称区分大小写。使用正确区分大小写的字体文件名

我的字体文件名是Prata-Regular\u 0.ttf

所以我输入这个:

@font-face {
    font-family: 'Prata-Regular_0';
    src: url("http:// YOUR DOMAIN .com/assets/fonts/Prata-Regular_0.ttf"); 

}
不是这样的:

@font-face {
   font-family: 'Prata-Regular_0';
   src: url("http:// YOUR DOMAIN .com/assets/fonts/prata-regular_0.ttf"); 
    
}

伙计们,这很有效…

谢谢,但这个解决方案确实有效。更新qusetionI我是php/codeigniter的新手。它会做什么?我需要创建“资产”文件夹并在这里输入“css”、“js”和“字体”目录?所有这些都很简单?我照你说的做,但没有任何变化。你能检查控制台吗?检查CSS是否正确加载。检查字体文件是否已加载。如果您使用的是Firebug,请查看“控制台”选项卡和“网络”选项卡。
@font-face {
    font-family: 'Prata-Regular_0';
    src: url("http:// YOUR DOMAIN .com/assets/fonts/Prata-Regular_0.ttf"); 

}
@font-face {
   font-family: 'Prata-Regular_0';
   src: url("http:// YOUR DOMAIN .com/assets/fonts/prata-regular_0.ttf"); 
    
}