2014-04-10 26 views
0

這兩個結構有什麼區別嗎?URL結構可能會破壞WebFont嗎?

以http://

@font-face { 
    font-family: 'nexa-boldregular'; 
    src: url('http://example.com/fonts/nexa_bold_webfont.eot'); 
    src: url('http://example.com/fonts/nexa_bold_webfont.eot?#iefix') format('embedded-opentype'), url('http://example.com/fonts//nexa_bold_webfont.woff') format('woff'), url('http://example.com/fonts//nexa_bold_webfont.ttf') format('truetype'), url('http://example.com/fonts//nexa_bold_webfont.svg#nexa_boldregular') format('svg'); 
    font-weight: normal; 
    font-style: normal; 
} 

不包含http://

@font-face { 
    font-family: 'nexa-boldregular'; 
    src: url('//example.com/fonts/nexa_bold_webfont.eot'); 
    src: url('//example.com/fonts/nexa_bold_webfont.eot?#iefix') format('embedded-opentype'), url('//example.com/fonts//nexa_bold_webfont.woff') format('woff'), url('//example.com/fonts//nexa_bold_webfont.ttf') format('truetype'), url('//example.com/fonts//nexa_bold_webfont.svg#nexa_boldregular') format('svg'); 
    font-weight: normal; 
    font-style: normal; 
} 

如果是這樣,請解釋。

另外:從我的測試中可以看出,Chrome可以讀取其中任何一種結構,但Firefox不能。

回答

0

//表格沒有http:稱爲protocol (or scheme) relative URL

如果將以//開頭的鏈接添加到http頁面(或通過http獲取的css文件),則字體將通過http獲取,而如果鏈接添加到https頁面,字體也會自動通過https獲取。

+0

這是一個很好的答案 - 謝謝。我在週末想出了真正的問題。事實證明,IE和Firefox掛在跨域請求上,而webkit沒有。 – staypuftman