首页 > 解决方案 > 在拥有的远程服务器上实现自定义字体不起作用

问题描述

我正在尝试在拥有的远程服务器上使用字体,但它没有在 Mailchimp 中加载。你能看一下代码,让我知道我应该去哪里解决问题吗?谢谢

<link href="https://.................ttf" rel="stylesheet" type="text/css" />
<style type="text/css">h1,h2,h3,h4,h5,p { 
   font-family: 'iransans', serif !important; 
   font-weight: 300 !important; 
} 
h1 { 
   line-height:44px !important; 
   color: #111 !important;
} 

</style>
<h1>Testing<br />
Marketing academy</h1>

标签: htmlcssimportfonts

解决方案


您正在使用不正确的方法来初始化字体。正确的是

<style type="text/css">
@font-face {
    font-family: 'iransans'; 
    src: url(https://.................ttf) format("truetype");
}
h1,h2,h3,h4,h5,p  { 
    font-family: 'iransans', serif !important; 
}
h1 { 
   line-height:44px !important; 
   color: #111 !important;
} 
</style>
<h1>Testing<br />
Marketing academy</h1>

更新

或者使用以下代码制作一个单独的文档,例如iransans.cssstile (有时标签会被邮件客户端忽略):

@font-face {
    font-family: 'iransans'; 
    src: url(https://.................ttf) format("truetype");
}

然后你可以添加到你的html:

<link href="https://yourdomain.com/iransans.css" rel="stylesheet" type="text/css">

它们添加为样式或单行:

<p style="font-family: ‘iransans’, Arial, sans-serif;">...</p>

但!如果您想在 Gmail 中使用自定义字体 - 您只能从这里使用一种https://fonts.google.com/


推荐阅读