这些年来,我使用了以下字体声明:
@font-face {
font-family: 'museo_sans_rounded';
font-style: normal;
font-weight: 500;
src: url('../fonts/museo/museosansrounded-300-webfont.eot');
src: url('../fonts/museo/museosansrounded-300-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/museo/museosansrounded-300-webfont.woff2') format('woff2'),
url('../fonts/museo/museosansrounded-300-webfont.woff') format('woff'),
url('../fonts/museo/museosansrounded-300-webfont.ttf') format('truetype'),
url('../fonts/museo/museosansrounded-300-webfont.svg#museo_sans_rounded300') format('svg');
}
现在,我只需要支持IE11和所有现代浏览器即可。可以简化此声明吗?
答案 0 :(得分:2)
根据embedding custom fonts上的这篇文章,使用@font-face
:
@ font-face规则允许将自定义字体加载到网页上。一旦添加到样式表,该规则就会指示浏览器从托管位置下载字体,然后按照CSS中的指定显示字体。
浏览器对各种字体的支持程度各不相同。趋势似乎是您可以摆脱提供WOFF和WOFF2的束缚,但这是他们对“尽可能深的浏览器支持”的建议:
@font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('webfont.woff2') format('woff2'), /* Super Modern Browsers */
url('webfont.woff') format('woff'), /* Pretty Modern Browsers */
url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}
对于IE11:
@font-face {
font-family: 'MyWebFont';
src: url('myfont.woff2') format('woff2'),
url('myfont.woff') format('woff'),
url('myfont.ttf') format('truetype');
}
答案 1 :(得分:0)
.eot ==> for IE9 Compat Modes
.eot?#iefix ==> for IE6-IE8
.woff2 ==> for super Modern browser like Chrome, Firefox...
.woff ==> for pretty Modern.. so to speak
.ttf ==> specially for Safari, Android, iOS
.svg#svgFontName ==> just for Legacy iOS