【问题标题】:Using @font-face in HTML在 HTML 中使用 @font-face
【发布时间】:2021-01-04 12:20:19
【问题描述】:

最近,我重新开始编写代码,并想通过做一个小网站来练习。所以,我想用@font-face 来定义一个自定义字体,而且我知道应该这样做(我的字体叫做 Champagne & limousines):

<style>

  @font-face {
      font-family: 'Champagne & Limousines';
      src: url('/fonts/Champagne & Limousines.eot');
      src: url('/fonts/Champagne & Limousines.woff2') format('woff2'),
           url('/fonts/Champagne & Limousines.woff') format('woff'),
           url('/fonts/Champagne & Limousines.ttf') format('truetype'),
           url('/fonts/Champagne & Limousines.svg#Champagne & Limousines') format('svg'),
           url('/fonts/Champagne & Limousines.eot?#iefix') format('embedded-opentype');

font-weight: normal;
font-style: normal;


 }

不过,我想知道为什么我们不必在每行之前加上“src:”。有人能教我这背后的逻辑吗?

谢谢。

【问题讨论】:

    标签: html css logic font-face


    【解决方案1】:

    对于在 html 中使用 font-face,你应该在你想要的某些部分使用,例如,如果我想使用 'Vazir-Fd'(这是我国家常用的字体),我是这样使用的:

    @font-face{
    font-family:'Vazir-FD',
    
      `src:url('/path')`
     }
    
    
    body{
    font-family:'Vazir-FD'
    }
    

    在这种情况下,我将它插入正文中,您可以在任何您喜欢的地方输入您的字体系列。

    【讨论】:

      猜你喜欢
      • 2015-03-05
      • 2016-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-25
      • 1970-01-01
      相关资源
      最近更新 更多