Nat*_*ams 11 html email templates mjml
我正在尝试实现一个使用带有 mjml 的超棒字体的电子邮件模板,我不知道该怎么做。我尝试使用 cdn 如下:
<mj-head>
<mj-title>Thank you!</mj-title>
<mj-style>
<mj-include path="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"/>
</mj-style>
<mj-attributes>
...
</mj-attributes>
</mj-head>
...
<mj-text align="center">
<h3>
Share <i class="fab fa-facebook-f"></i>
</h3>
</mj-text>
...
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用。任何人都可以建议我如何最好地做到这一点?
首先,您需要包含字体。
<mjml>
<mj-head>
<mj-font name="FontAwesome" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"/>
</mj-head>
</mjml>
Run Code Online (Sandbox Code Playgroud)
之后,您需要找到您希望使用的字体的 unicode 编号。如果您拉出星形图标页面,您可以看到它是f005。
现在您可以使用mj-text标签来包含字体。
<mj-text font-family="FontAwesome"></mj-text>
Run Code Online (Sandbox Code Playgroud)
这适用于实体图标。fas类和的图标之间的区别far在于其fas权重为 900 和far400。但是,在我的测试中,更改font-weight并没有产生任何不同的结果。我确实发现我可以far使用 f006 获取星形图标的版本。我检查了其他图标,将 unicode 数字加一的简单操作不起作用。我发现获得 Font Awesome 上未列出的图标的 unicode 等效项的最佳方法是使用类似的东西在普通网页中呈现它,<i class="far fa-star"></i>"然后将图标复制并粘贴到http://unicode.scarfboy.com/