我需要在网站上使用4个字体,我的网站文件夹中有文件
Baskerville.ttc
BellGothicstd-Black.otf
BellGothicstd-Bold.otf
JennaSue.ttf
Run Code Online (Sandbox Code Playgroud)
我试图导入使用@Import并且这里的字体仍然不起作用是我使用的:
@import url(../fonts/BellGothicStd-Black.otf);
@import url(../fonts/BellGothicStd-Bold.otf);
@import url(../fonts/Baskerville.ttc);
@import url(../fonts/JennaSue.ttf);
Run Code Online (Sandbox Code Playgroud)
我也尝试使用@ font-face规则这是我使用的:
@font-face {
font-family: 'BellGothicBlack';
src: url('../fonts/BellGothic-Black.otf') format('OpenType'),
}
@font-face {
font-family: 'BellGothicBold';
src: url('../fonts/BellGothicStd-Bold.otf') format('OpenType'),
}
@font-face {
font-family: 'Baskerville';
src: url('../fonts/Baskerville.ttc') format('OpenType'),
}
@font-face {
font-family: 'JennaSue';
src: url('../fonts/JennaSue.ttf') format('TrueType'),
}
Run Code Online (Sandbox Code Playgroud)
有人能告诉我我做错了什么吗?我想我可能会遗漏一些我不太确定的代码.
先谢谢汤姆
您需要将字体转换为所有浏览器的正确格式才能显示它们.(在执行此操作之前检查权限)
http://www.fontsquirrel.com/tools/webfont-generator
您的@font-face规则还需要包含所有字体类型......
例:
@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 */
}
Run Code Online (Sandbox Code Playgroud)