在较少的css中使用@ font-face和url

时间:2012-11-26 12:05:33

标签: css css3 less

我有一个网址(../font/Lato/Lato-Regular.ttf)我如何使用@ font-face少用css?

试过这个但不起作用

.font(@fontName:"Lato"){
  font-family:@fontName;
}

.fontFace(@fontName:"Lato", @fontFile: '../font/Lato/Lato-Regular')
{
  font-family: @fontName;
  src: url('@{fontFile}.ttf');
}

.latoFont
{
  .font();
  @font-face{
   .fontFace();
  }

}

1 个答案:

答案 0 :(得分:2)

你应该这样写: -

@font-face {
    font-family: 'MyWebFont';
    src: url('webfont.eot'); /* IE9 Compat Modes */
    src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
         url('webfont.woff') format('woff'), /* Modern Browsers */
         url('webfont.ttf')  format('truetype'), /* Safari, Android, iOS */
         url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
    }

Or Read More About how to use custom fonts for our websites.....