2012-04-02 94 views
4

目前我使用@font-face与不支持的浏览器回退:覆盖字体重量@字体面

@font-face 
{ 
    font-family: TheSansBlack; 
    src: local(TheSansBlack), url(../fonts/TheSans_TT9_.woff) format('woff'); 
} 

font-family: TheSansBlack, Arial, Verdana, Helvetica, sans-serif; 

在某些情况下,备用要大胆,所以我有一些CSS的符号,如:

#foo 
{ 
    font-family: TheSansBlack, Arial, Verdana, Helvetica, sans-serif; 
    font-weight: bold; 
} 

而且因为我使用了一个名为字体TheSansBlack没有必要设置font-weight: bold

但是这是不行的:

@font-face 
{ 
    font-family: TheSansBlack; 
    font-weight: normal; 
    src: local(TheSansBlack), url(../fonts/TheSans_TT9_.woff) format('woff'); 
} 

它仍然显示了大胆的其中一个相貌丑陋,因为它是双大胆与TheSansBlack ... 我只需要字体重量设置为粗体的回退,而不是WOFF字体。

编辑:我也试过这个没有成功:

@font-face 
{ 
    font-family: TheSansBlack; 
    src: local(TheSansBlack), url(../fonts/TheSans_TT9_.woff) format('woff'); 

    #foo 
    { 
    font-weight: normal !important; 
    } 
} 

#foo 
{ 
    font-family: TheSansBlack, Arial, Verdana, Helvetica, sans-serif; 
    font-weight: bold; 
} 
+0

嗨,你可以把HTML代码和jsfiddle链接? – 2012-04-02 11:54:44

+0

@azad如何使用非自由字体做到这一点? ;-)是不是没用了呢? – dtrunk 2012-04-02 12:15:21

回答

1

明白了:-)

我必须明确地设置字体,重量大胆@字体面。

说不上为什么...

编辑:完整的例子

@font-face 
{ 
    src: local(TheSansBlack), url(../fonts/TheSans_TT9_.woff) format('woff'); 
    font-family: TheSansBlack; 
    font-weight: bold; 
} 

#foo 
{ 
    font-family: TheSansBlack, Arial, Verdana, Helvetica, sans-serif; 
    font-weight: bold; 
} 

这导致正常TheSansBlack和大胆的宋体/宋体/黑体在旧的浏览器。

+0

原因是font-face内的font-weight会告诉浏览器字体*是*粗体。 – 2018-02-01 13:11:30