嗨,我有一个关于使用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 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呈现,或者浏览器是否会尝试模拟它而不使用实际的粗体字体文件?
谢谢
发布于 2014-01-29 23:26:03
下面是我使用的一个示例:
@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;
}同时设置font-weight: normal;和font-style: normal;使字体在ie/ff/chrome中呈现良好,如果没有它,它在Chrome中看起来就像垃圾一样。我认为它在Chrome中看起来像垃圾,因为它试图用粗体呈现粗体字体,这应该通过这个来修复。
编辑:拼写
发布于 2014-01-29 23:41:47
如果您的字体文件是粗体字体,则设置font-weight: bold将是多余的,并且不需要声明font-weight: normal,因为这是默认值。您还应该使用更多的.eot文件,这样您就可以像其他人建议的那样,为其他浏览器提供后备。
https://stackoverflow.com/questions/21434594
复制相似问题