2014-12-09 58 views
0

我想在我的應用程序中添加自定義字體,但它不起作用。 這是路徑時,字體位於位於system/fonts/JtNLnKEa自定義字體不起作用。代碼

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; 
} 

如何解決

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

字體?

對不起,我英文不好

回答

0

添加您的字體到您的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'; 
} 

編輯:

body,html { 
    font-family: "PF Din Text Cond Pro"; /* Add double quotes around your custom font name */ 
    height: 100%; 
    min-height: 100%; 
    margin-top: 0px; 
} 
+0

謝謝,但是這個解決方案確實有效。更新查詢 – vveare138 2014-12-09 11:44:03

+0

回答更新,請檢查。 – Pupil 2014-12-09 11:46:26

0
@font-face { 
    font-family:'Lucida Grande'; 
    font-style: normal; 
    font-weight: 100; 
    src: url(../fonts/6216.ttf) format('ttf'); 
} 
@font-face { 
    font-family:'Myriad Set Pro'; 
    font-style: normal; 
    font-weight: 100; 
    src: url(../fonts/myriad.woff) format('woff'); 
} 
@font-face { 
    font-family:'Helvetica Neue'; 
    font-style: normal; 
    font-weight: 100; 
    src: url(../fonts/helvetica-neue-medium.ttf) format('ttf'); 
} 
@font-face { 
    font-family:'Roboto'; 
    font-style: normal; 
    font-weight: 100; 
    src: url(../fonts/helvetica-neue-medium.ttf) format('ttf'); 
} 
body 
{ 
    font-family:"Myriad Set Pro","Lucida Grande","Helvetica Neue","Helvetica","Arial","Verdana","sans-serif"; 
    overflow-x:hidden !important; 
} 

在根文件夾資產/ CSS /字體

0

您appliation structuer應像這樣

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

等。

那麼你訪問的網址應該像http://contrast-energo.ru/assets/fonts/JtNLnKEa.ttf

+0

我是新手在php/codeigniter.What它會做什麼,我需要創建'資產'文件夾,並在這裏輸入'css','js'和'字體'目錄?這一切都很簡單嗎? – vveare138 2014-12-09 12:12:07

0

你的問題是不相關的笨。您在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元素,你可以使用以下命令:

body {font-family:'PF Din Text Cond Pro', Arial, sans-serif;} 

你需要單引號或雙引號之間添加字體名稱,因爲它是一個自定義的字體。

如果您只有「.otf」或「.ttf」字體文件,則需要將此文件轉換爲其他格式。

Online Font Converter是最好的免費字體轉換器那裏。

+0

我照你說的做,但沒有變化 – vveare138 2014-12-09 14:20:30

+0

你可以檢查控制檯嗎?檢查CSS是否正確加載。檢查字體文件是否已加載。如果您使用的是Firebug,請查看「控制檯」選項卡和「網絡」選項卡。 – 2014-12-09 14:27:35