简体   繁体   English

响应式HTML电子邮件模板

[英]Responsive HTML E-Mail Template

I'm a Software Developer (mainly Frontend), so I'm used to code in a responsive way. 我是一名软件开发人员(主要是Frontend),所以我习惯于以响应方式进行编码。

Now I stumbled upon a task to create an email template and did a bit of a research. 现在,我偶然发现了一个创建电子邮件模板的任务,并做了一些研究。 What I found out that you have very limited ways to achieve things which are quite basic in software development. 我发现,实现软件开发中非常基本的功能的方法非常有限。

Could someone who has experience with developing email templates answer the following questions: 有开发电子邮件模板经验的人可以回答以下问题:

  • Can e-mails be developed in a responsive way (ie. with Bootstrap Grid columns, layout breakpoints etc.)? 电子邮件是否可以响应式方式开发(即使用Bootstrap Grid列,布局断点等)? I've read in some threads that in order to support all clients I need to use a table layout. 我读过一些文章,为了支持所有客户端,我需要使用表布局。

  • Can I use CSS tags as in a normale app? 我可以像在普通应用中一样使用CSS标签吗? (Meaning, not only inline, but also have a seperate style tag)? (意思是,不仅是内联的,而且还有单独的样式标签)?

  • For fonts and spacing: Can I use em or rem instead of pixels? 对于字体和间距:是否可以使用emrem代替像素? I would like to cover screens which do not use the default font layout. 我想覆盖不使用默认字体布局的屏幕。

  • I found a bootstrap library for emails which seems to solve all these issues and support many email clients: https://bootstrapemail.com/ . 我找到了一个用于电子邮件的引导程序库,该程序库似乎可以解决所有这些问题并支持许多电子邮件客户端: https : //bootstrapemail.com/ Can someone tell me if this solves the issues? 有人可以告诉我是否可以解决问题?

  1. Can e-mails be developed in a responsive way (ie. with Bootstrap Grid columns, layout breakpoints etc.)? 电子邮件是否可以响应式方式开发(即使用Bootstrap Grid列,布局断点等)?

Yes, you can use bootstarp classes in HTML tag as like a web page. 是的,您可以像在网页中一样在HTML标记中使用bootstarp类。

<button type="button" class="btn btn-success">Success</button>
  1. Can I use CSS tags as in a normale app? 我可以像在普通应用中一样使用CSS标签吗? (Meaning, not only inline, but also have a seperate style tag)? (意思是,不仅是内联的,而且还有单独的样式标签)?

Yes, You can use style tag for styling but not sure about external css. 是的,您可以使用样式标签进行样式设置,但不确定外部CSS。

<style type="text/css">
    body {
        width: 100%;
        background-color: #ffffff;
    }
</style>
  1. For fonts and spacing: Can I use em or rem instead of pixels? 对于字体和间距:是否可以使用em或rem代替像素? I would like to cover screens which do not use the default font layout. 我想覆盖不使用默认字体布局的屏幕。

In my opinion, using px is the best way when coding for HTML email. 我认为,使用px是编码HTML电子邮件的最佳方法。 You can also read more about In email templates, should font-size be in pt or px? 您还可以阅读有关在电子邮件模板中的更多信息,字体大小应为pt还是px?

  1. Bootstrap for Email Templates 电子邮件模板的引导程序

It is a best way to develop custom and responsive email templates. 这是开发自定义和响应式电子邮件模板的最佳方法。 It is supported many Email Clients like Yahoo, Gmail, AOL Mail, Outlook, Apple mail, etc... Essay to use and lot of examples available online. 它支持许多电子邮件客户端,例如Yahoo,Gmail,AOL Mail,Outlook,Apple Mail等。

  • Using css as normal apps might not work for every client, it's best to work inline and also you can use internal css for stacking on devices. 将css用作普通应用程序可能不适用于每个客户端,最好是内联工作,也可以使用内部css在设备上进行堆栈。
  • Pixel is the best option for emails 像素是电子邮件的最佳选择
  • Personally, I never used Bootstrap 4 emails but it can be used as it supports lots of email clients 就个人而言,我从未使用过Bootstrap 4电子邮件,但可以使用它,因为它支持许多电子邮件客户端

I have added my working code that supports almost every client. 我添加了支持几乎所有客户端的工作代码。 You can review the code. 您可以查看代码。 Hope it'd help you to understand emails better! 希望它能帮助您更好地了解电子邮件!

Here is the link: https://codepen.io/nazifa1022/pen/dxNNBg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM