從自己服務器加載谷歌字體,解決googleapis加載慢的問題
- 分類:博文-IT資訊
- 發布于 2017年2月07日 星期二 16:26
- 作者:Super User
- 點擊數:21191
假設要使用open sans400和700的字體,將IE瀏覽器調到IE8模式,打開這倆地址,友情提示不翻墻可能打不開。
?
http://fonts.googleapis.com/css?family=Open+Sans:400
http://fonts.googleapis.com/css?family=Open+Sans:700
會得到這么一段樣式(400的)
|
1
2
3
4
5
6
7
|
@font-face {??font-family: 'Open Sans';??font-style: normal;??font-weight: 400;??src: url(http://themes.googleusercontent.com/static/fonts/opensans/v8/cJZKeOuBrn4kERxqtaUH3fY6323mHUZFJMgTvxaG2iE.eot);??src: local('Open Sans'), local('OpenSans'), url(http://themes.googleusercontent.com/static/fonts/opensans/v8/cJZKeOuBrn4kERxqtaUH3fY6323mHUZFJMgTvxaG2iE.eot) format('embedded-opentype'), url(http://themes.googleusercontent.com/static/fonts/opensans/v8/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff) format('woff');} |
里面有倆鏈接,一個是eot字體,一個是woff字體,在瀏覽器里分別下載這倆字體,在主題里新建個fonts目錄,放進去,名字改的好認點,比如opensans.eot,opensans.woff。
然后上面那個樣式改成下面這樣,直接扔進主題樣式表里。
|
1
2
3
4
5
6
7
|
@font-face {??font-family: 'Open Sans';??font-style: normal;??font-weight: 400;??src: url(fonts/opensans.eot);??src: local('Open Sans'), local('OpenSans'), url(fonts/opensans.eot) format('embedded-opentype'), url(fonts/opensans.woff) format('woff');} |
這樣字體文件就是從自己服務器加載了,當然是用其它CDN服務也可以。





