正确使用CSS@font-face
您好,我有一个关于使用CSS@font-face创建字体系列的快速问题 传统上,我习惯这样设置CSS字体:正确使用CSS@font-face,css,fonts,Css,Fonts,您好,我有一个关于使用CSS@font-face创建字体系列的快速问题 传统上,我习惯这样设置CSS字体: @font-face { font-family: 'My Font Regular'; src: url('fonts/myfont.ttf'); } @font-face { font-family: 'My Font Bold'; src: url('fonts/myfont-bold.ttf'); } p { font-family: "My Fon
@font-face {
font-family: 'My Font Regular';
src: url('fonts/myfont.ttf');
}
@font-face {
font-family: 'My Font Bold';
src: url('fonts/myfont-bold.ttf');
}
p { font-family: "My Font Regular";}
strong {font-family: "My Font Bold";}
@font-face {
font-family: 'My Font';
src: url('fonts/myfont.ttf');
font-style:normal;
font-weight:normal;
}
@font-face {
font-family: 'My Font';
src: url('fonts/myfont-bold.ttf');
font-style:normal;
font-weight:bold;
}
p {
font-family: "My Font" ;
font-style:normal;
font-weight:normal;
}
strong {
font-family: "My Font" ;
font-style:normal;
font-weight:bold;
}
但我最近发现,你可以这样做:
@font-face {
font-family: 'My Font Regular';
src: url('fonts/myfont.ttf');
}
@font-face {
font-family: 'My Font Bold';
src: url('fonts/myfont-bold.ttf');
}
p { font-family: "My Font Regular";}
strong {font-family: "My Font Bold";}
@font-face {
font-family: 'My Font';
src: url('fonts/myfont.ttf');
font-style:normal;
font-weight:normal;
}
@font-face {
font-family: 'My Font';
src: url('fonts/myfont-bold.ttf');
font-style:normal;
font-weight:bold;
}
p {
font-family: "My Font" ;
font-style:normal;
font-weight:normal;
}
strong {
font-family: "My Font" ;
font-style:normal;
font-weight:bold;
}
我的问题是,例如,如果我使用第二种粗体技术,文本是否仍然使用自定义.eot进行渲染,或者浏览器是否会尝试在不使用实际粗体字体文件的情况下模拟它
谢谢以下是我使用的示例:
@font-face {
font-family: 'Franklin Demi';
src: url('FranklinDemi.eot'),
url('FranklinDemi.ttf') format('truetype'),
url('FranklinDemi.svg#font') format('svg');
}
@font-face {
font-family: 'Franklin Heavy';
src: url('FranklinHeavy.eot'),
url('FranklinHeavy.ttf') format('truetype'),
url('FranklinHeavy.svg#font') format('svg');
}
.sidansTitel{
font-family: 'Franklin Demi';
font-size: 22pt;
color: #8b9ba7;
text-shadow: 0 1px 0 rgba(0,0,0,0.01);
}
.sidansTitel b{
font-family: 'Franklin Heavy';
font-weight: normal;
font-style: normal;
}
同时设置字体大小:正常代码>和字体样式:正常
使字体在ie/ff/chrome中呈现良好,没有它,在chrome中看起来就像垃圾。我相信它在Chrome中看起来像垃圾,因为它试图以粗体呈现粗体字体,这应该通过这个来修复
编辑:拼写如果字体文件是粗体字体,则设置字体重量:粗体
是多余的,并且无需声明字体重量:正常
,因为这是默认值。您还应该使用更多的.eot
文件,以便您可以像其他建议的浏览器一样使用其他浏览器。请参阅。作为旁注,请注意。这正是我想要的。谢谢