在CSS中应用font-face的正确方法是什么?

时间:2013-11-08 11:21:00

标签: html5 css3 fonts font-face

目前,我正如以下示例那样做,这是正确的吗?有没有更好的方法呢?

/*Font Face*/
@font-face { font-family: Comfortaa; src: url('Comfortaa.ttf') }
@font-face { font-family: Comfortaa; font-weight: bold; src: url('ComfortaaBOLD.ttf') }

/*Fonts*/h1, h2, h3, h4, h5, h6, p, pre, a, ol, li, span, label, blockquote, figcaption, abbr, td, input, textarea {
    font-family: 'Comfortaa', arial, sans-serif; 
    font-size: 1em;
    line-height: 150%;
    color: #4A4A4A;
}

2)应用BOLD字体的下列哪种方法是正确的:

A)

strong {
   font-weight: bold;
}

B)

strong {
   font-family: Comfortaa; font-weight: bold; src: url('ComfortaaBOLD.ttf')
}

1 个答案:

答案 0 :(得分:0)

通常你会这样做:

@font-face { font-family: Comfortaa; font-weight: normal; src: url('Comfortaa.ttf') }
@font-face { font-family: ComfortaaBold; font-weight: normal; src: url('ComfortaaBOLD.ttf') }

/*Fonts*/h1, h2, h3, h4, h5, h6, p, pre, a, ol, li, span, label, blockquote, figcaption, abbr, td, input, textarea {
    font-family: 'Comfortaa', arial, sans-serif; 
    font-size: 1em;
    line-height: 150%;
    color: #4A4A4A;
}

strong {
   font-family: 'ComfortaaBold';
   font-weight: normal;
}

由于您已导入粗体字体,因此无需再次将字体粗细设置为粗体。而是将其设置为正常,以使其在屏幕上很好地呈现。