2013-12-12 20 views
0

我在html和css中有一個代碼。我想用特殊字體我已經下載和搜索一些後,我寫了下面的代碼:在html和css中使用特定字體

<head> 
     <style> 
     @font-face 
     { 
      font-family: paraaminobenzoic; 
      src: url('paraaminobenzoic.otf'); 
     } 
     p.custom_font {font-family: paraaminobenzoic;} 
     </style> 
    </head> 

,它不工作,我不知道爲什麼。特別是我不知道我是否將下面的代碼添加到了正確的位置。

p.custom_font {font-family: paraaminobenzoic;}

誰能幫助注意到這個問題?

+0

@JTFRage感謝。 :)我沒有看到SO上的鏈接。它幫助並且是正確的。 :) –

+0

沒問題,不要忘了把問題標記爲已回答。 – JTFRage

回答

2

爲字型的正確格式應該是:

@font-face{ 
font-family: 'MyWebFont'; 
src: url('WebFont.eot'); 
src: url('WebFont.eot?iefix') format('eot'), 
    url('WebFont.woff') format('woff'), 
    url('WebFont.ttf') format('truetype'), 
    url('WebFont.svg#webfont') format('svg'); 
} 

TTF - 除了IE瀏覽器和iPhone的大多數瀏覽器上運行。

僅限EOT-IE。

WOFF - 壓縮的新興標準。

SVG - iPhone/iPad。

到這裏看看: http://www.fontspring.com/support/installing_webfonts/how-do-i-use-the-webfonts

+0

實際上,.svg僅適用於iOS 5及更早版本。 – KaptajnKold

+0

@ wf4感謝提到這些細節。我不知道他們。 :) –

1

嘗試以下方式加上引號 -

<head> 
    <style> 
    @font-face { 
     font-family: "paraaminobenzoic"; 
     src: url("paraaminobenzoic.otf"); 
    } 
    p.custom_font { 
     font-family: "paraaminobenzoic"; 
    } 
    </style> 
</head>