实际上我在fonts文件夹中有三个文件.这是Gotham-Bold.ttf,Gotham-Medium.ttf,Gotham-Thin.ttf.....所以,我需要使用@font-face三次,这三种类型的.请有人帮助我.
我目前使用的代码如下:
@font-face {
font-family: 'Gotham';
src: url('fonts/Gotham-Bold.eot'); /* IE9 Compat Modes */
src: url('fonts/Gotham-Bold.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/Gotham-Bold.woff') format('woff'), /* Modern Browsers */
url('fonts/Gotham-Bold.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/Gotham-Bold.svg#svgFontName') format('svg'); /* Legacy iOS */
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Gotham';
src: url("/fonts/Gotham-Bold.eot");
}
@font-face {
font-family: 'Gotham';
src: url("/fonts/Gotham-Bold.woff") format("woff");
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
这是正确的,你需要@font-face为你想要使用的每个字体重量.
@font-face {
font-family: 'Gotham';
src: url('fonts/Gotham-Bold.eot'); /* IE9 Compat Modes */
src: url('fonts/Gotham-Bold.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/Gotham-Bold.woff') format('woff'), /* Modern Browsers */
url('fonts/Gotham-Bold.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/Gotham-Bold.svg#svgFontName') format('svg'); /* Legacy iOS */
font-weight: 700;
font-style: normal;
}
@font-face {
font-family: 'Gotham';
src: url('fonts/Gotham-Medium.eot'); /* IE9 Compat Modes */
src: url('fonts/Gotham-Medium.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/Gotham-Medium.woff') format('woff'), /* Modern Browsers */
url('fonts/Gotham-Medium.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/Gotham-Medium.svg#svgFontName') format('svg'); /* Legacy iOS */
font-weight: 400;
font-style: normal;
}
@font-face {
font-family: 'Gotham';
src: url('fonts/Gotham-Thin.eot'); /* IE9 Compat Modes */
src: url('fonts/Gotham-Thin.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/Gotham-Thin.woff') format('woff'), /* Modern Browsers */
url('fonts/Gotham-Thin.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/Gotham-Thin.svg#svgFontName') format('svg'); /* Legacy iOS */
font-weight: 300;
font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)
然后您可以使用您的字体:
body {
font-family: 'Gotham';
}
// For normal
.normal {
font-weight: 400;
}
// For bold
.bold,
strong {
font-weight: 700;
}
// For thin
.light {
font-weight: 300;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
44247 次 |
| 最近记录: |