首先保证路径正确,引入ttf字体,没有生效

@font-face定义的字体没有生效

 

 @font-face定义的字体没有生效

 

 

使用在线工具把ttf转为更多常用的字体格式

网址:https://www.fontke.com/tool/convfont/

@font-face定义的字体没有生效

 

 

css里补全格式:

@font-face定义的字体没有生效

 

 生效了

@font-face定义的字体没有生效

 

还有另一种原因,就是服务器没有在iis里加字体文件的映射

解决方法:

添加MIME类型映射

直接在IIS面板中的 MIME类型 中添加对应的信息,具体类型信息可参考 W3CSchool MIME 参考手册
为了保险起见可在配置文件中添加MIME映射的信息:

<configuration>
    <system.webServer>
        <staticContent>
            <remove fileExtension=".woff"/>
            <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
            <remove fileExtension=".woff2"/>
            <mimeMap fileExtension=".woff2" mimeType="application/x-font-woff2" />
            <remove fileExtension=".ttf" />
            <mimeMap fileExtension=".ttf" mimeType="application/x-font-truetype" />
            <remove fileExtension=".svg" />
            <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
            <remove fileExtension=".otf" />
            <mimeMap fileExtension=".otf" mimeType="application/x-font-opentype" />
            <remove fileExtension=".eot" />
            <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
        </staticContent>
    </system.webServer>
</configuration>

 

相关文章:

  • 2021-04-14
  • 2021-09-07
  • 2022-02-18
  • 2021-10-07
  • 2022-02-20
  • 2021-09-25
  • 2022-01-08
  • 2021-05-29
猜你喜欢
  • 2021-11-19
  • 2022-12-23
  • 2021-12-25
  • 2021-10-07
  • 2022-01-01
  • 2022-12-23
相关资源
相似解决方案