我嘗試使用面部字體將幾個字體添加到我的頁面,但不幸的是,即使我按照說明使其與瀏覽器兼容,它僅適用於Chrome和Safari我無法弄清楚爲什麼。我嘗試了兩種不同的方法。font-face不適用於所有瀏覽器
第一個看起來是這樣的:
@font-face {
font-family: 'robotoblack';
src: url('roboto-black-webfont.eot'); /* per IE 5-8 */
src: local('☺'), /* direttiva local per IE */
url('roboto-black-webfont.woff') format('woff'), /* Firefox 3.6+, Chrome 5.0+, IE 9.0+ */
url('roboto-black-webfont.ttf') format('truetype'); /* Opera, Safari */
}
@font-face {
font-family: 'robotomedium_italic';
src: url('roboto-mediumitalic-webfont.eot'); /* per IE 5-8 */
src: local('☺'), /* direttiva local per IE */
url('roboto-mediumitalic-webfont.woff') format('woff'), /* Firefox 3.6+, Chrome 5.0+, IE 9.0+ */
url('roboto-mediumitalic-webfont.ttf') format('truetype'); /* Opera, Safari */
}
,第二個是這樣的:
@font-face {
font-family: 'robotoblack';
src: url('roboto-black-webfont.eot'); /* IE9 Compat Modes */
src: url('roboto-black-webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('roboto-black-webfont.woff2') format('woff2'), /* Super Modern Browsers */
url('roboto-black-webfont.woff') format('woff'), /* Pretty Modern Browsers */
url('roboto-black-webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('roboto-black-webfont.svg#robotoblack') format('svg'); /* Legacy iOS */
}
@font-face {
font-family: 'robotomedium_italic';
src: url('roboto-mediumitalic-webfont.eot'); /* IE9 Compat Modes */
src: url('roboto-mediumitalic-webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('roboto-mediumitalic-webfont.woff2') format('woff2'), /* Super Modern Browsers */
url('roboto-mediumitalic-webfont.woff') format('woff'), /* Pretty Modern Browsers */
url('roboto-mediumitalic-webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('roboto-mediumitalic-webfont.svg#robotomedium_italic') format('svg'); /* Legacy iOS */
}
你能告訴我這兩種方法是最好的?任何建議,使其適用於所有瀏覽器?
在你想看到的例子情況下,可以在這裏找到:
我希望你能幫助!在此先感謝
乾杯
恩里科
您的字體不與stiles.css文件(我無法通過引用它們在瀏覽器中加載它們),它們在哪裏? –
他們在一個文件夾中,但是因爲您問了這個問題,我將它們複製到stile.css文件所在的主文件夾中。這是對的嗎?仍然沒有工作.... –