Multiple font-weights, one @font-face query

前端 未结 2 908
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 05:01

I have to import the Klavika font and I\'ve received it in multiple shapes and sizes:

Klavika-Bold-Italic.otf
Klavika-Bold.otf
Klavika-Light-Italic.otf
Klavi         


        
相关标签:
2条回答
  • 2020-12-02 05:30
    @font-face {
      font-family: 'Klavika';
      src: url(../fonts/Klavika-Regular.otf) format('truetype') font-weight-normal,
           url(../fonts/Klavika-Bold.otf) format('truetype') font-weight-bold,
           url(../fonts/Klavika-Bold-Italic.otf) format('truetype') font-italic font-weight-bold;
    }
    
    0 讨论(0)
  • 2020-12-02 05:32

    Actually there is a special flavor of @font-face that will permit just what you're asking.

    Here's an example using the same font-family name with different styles and weights associated with different fonts:

    @font-face {
      font-family: "DroidSerif";
      src: url("DroidSerif-Regular-webfont.ttf") format("truetype");
      font-weight: normal;
      font-style: normal;
    }
    
    @font-face {
      font-family: "DroidSerif";
      src: url("DroidSerif-Italic-webfont.ttf") format("truetype");
      font-weight: normal;
      font-style: italic;
    }
    
    @font-face {
      font-family: "DroidSerif";
      src: url("DroidSerif-Bold-webfont.ttf") format("truetype");
      font-weight: bold;
      font-style: normal;
    }
    
    @font-face {
      font-family: "DroidSerif";
      src: url("DroidSerif-BoldItalic-webfont.ttf") format("truetype");
      font-weight: bold;
      font-style: italic;
    }
    

    You can now specify font-weight:bold or font-style:italic to any element you like without having to specify the font-family or overriding font-weight and font-style.

    body { font-family:"DroidSerif", Georgia, serif; }
    
    h1 { font-weight:bold; }
    
    em { font-style:italic; }
    
    strong em {
      font-weight:bold;
      font-style:italic;
    }
    

    For a full overview of this feature and the standard use take a look at this article.


    EXAMPLE PEN

    0 讨论(0)
提交回复
热议问题