html - HTML 电子邮件中的响应框

标签 html css email html-email

我使用 ActiveCampaign 发送电子邮件,最近我开始构建 HTML 电子邮件以更好地控制情况。

ActiveCampaign 自动设置表格,因此我无需担心,因为它符合标准 HTML 和电子邮件 HTML。

我应该有一个响应行,其中的列会在用户在手机上查看电子邮件时自动换行。

我试图在电子邮件中构建一些列,我尝试使用 flexbox,但它在 Gmail 中不断给我错误。我什至尝试过,但它不包装内容。

在这里你可以找到完整的代码。 我突出显示了我遇到问题的部分。

.divmain {
  margin: 5px;
  border-radius: 5px;
  -moz-box-shadow: 0px 0 7px 0px #b5b5b5;
  -webkit-box-shadow: 0px 0 7px 0px #b5b5b5;
  box-shadow: 0px 0 7px 0px #b5b5b5;
}

.divp {
  background-image: url("http://i67.tinypic.com/jhzs0g.png"), linear-gradient(90deg, #FD8571, #EEBD7C);
  background-size: cover;
  background-position: bottom;
  background-repeat: no-repeat;
  width: auto;
  border-radius: 5px 5px 0px 0px;
  padding-left: 5%;
  padding-right: 5%;
  padding-top: 7%;
  padding-bottom: 7%;
  margin-bottom: 0;
  text-align: center;
}

.divs {
  background-image: url("http://i66.tinypic.com/350w10h.png"), linear-gradient(90deg, #7172fd, #bc7cee);
  background-size: cover;
  background-position: bottom;
  background-repeat: no-repeat;
  width: auto;
  border-radius: 0px 0px 5px 5px;
  padding-left: 5%;
  padding-right: 5%;
  padding-top: 7%;
  padding-bottom: 7%;
  margin-bottom: 0;
  text-align: center;
}

.divw {
  width: auto;
  padding-left: 7%;
  padding-top: 5%;
  padding-bottom: 1%;
  padding-right: 27%;
  text-align: left;
  border-style: solid;
  border-width: 0px 1px 0px 1px;
  border-color: #cecece;
  margin: 0;
}

.row {
  display: flex;
  justify-content: center;
  flex-flow: row wrap;
}

.column {
  flex: 33.33%;
  padding-left: 5%;
  padding-right: 5%;
  margin-bottom: 5%;
  margin-left: auto;
  margin-right: auto;
}

.columnbox {
  width: auto;
  border-radius: 8px;
  padding: 5%;
  text-align: center;
  border-style: solid;
  border-width: 1px;
  border-color: #cecece;
  -moz-box-shadow: 0px 0 7px 0px #b5b5b5;
  -webkit-box-shadow: 0px 0 7px 0px #b5b5b5;
  box-shadow: 0px 0 7px 0px #b5b5b5;
}

.row::after {
  content: "";
  clear: both;
  display: table;
}

.border-div {
  border-style: solid;
  border-width: 0px 1px 0px 1px;
  border-color: #cecece;
  border-radius: 0 0 3px 3px;
}
<!DOCTYPE html>
<html>

<head>
</head>

<body>

  <div class="divmain">

    <div class="divp">

      <h1 style="color:white; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em">Sei della Famiglia adesso!</h1>

      <p style="font-size: 1.4em; color: white; line-height: 150%;  font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-top: 0; padding-top: 0">Moover non è un semplice servizio,<br> è una fantastica community!
      </p>

      <div class="btn" style="background-color: #4E69C2; text-decoration: none; display: inline-block; border: 3px solid #4E69C2; border-radius: 7px; font-size: 1.4em; padding: 0.3em 1em; -webkit-font-smoothing: antialiased; color: #fff;"><a class="btn-link" href="https://moover.digital/" rel="noopener noreferrer" style="text-decoration: none; color: #fff; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; font-size: 0.8em; font-weight: 600; -webkit-font-smoothing: antialiased;"
          target="_blank">Scopri di più ►</a></div>

    </div>

    <div class="divw">

      <p style="font-size: 1.1em; line-height: 150%; color: #3b3b3b; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif"><b>Oh! Eccoti!</b><br> Volevamo informarti che il servizio di Crescita Organica è stato attivato con successo sul profilo @%USERNAME%
      </p>

      <p style="font-size: 1.1em; color: #4E69C2; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em;"><b>Il periodo di Prova Gratuita durerà 7 giorni!</b>
      </p>

      <p style="font-size: 1em; line-height: 150%; color: #3b3b3b; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-top: 0; padding-top: 0;">(Goditeli fino in fondo!)
      </p>

    </div>


    <!-- Here is where I have some problems -->


    <p class="border-div" style="margin: 0; text-align: center; font-size: 1.2em; line-height: 150%; color: #3b3b3b; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; font-weight: bold; padding-bottom: 1em; padding-top: 1em; ">Questi sono alcuni dati attuali del tuo account</p>

    <div class="row border-div desktop-view" style="padding-top: 1em; padding-right: 5%; padding-bottom: 3em; padding-left: 5%;">

      <div class="column">

        <div class="columnbox" style="margin-right: 5%;">
          <p style="font-size: 1em; color: rgb(78, 194, 136); font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em; font-weight: bold; margin-top: 0.2em;">Follower Attuali</p>
          <p style="font-size: 350%; color: #4E69C2; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em; font-weight: bold; margin-top: 0.2em;">99.000</p>
        </div>

      </div>

      <div class="column">

        <div class="columnbox" style="margin-right: 5%;">
          <p style="font-size: 1em; color: rgb(78, 194, 136); font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em; font-weight: bold; margin-top: 0.2em;">Likes Attuali</p>
          <p style="font-size: 350%; color: #4E69C2; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em; font-weight: bold; margin-top: 0.2em;">99.000</p>
        </div>

      </div>

      <div class="column">

        <div class="columnbox" style="margin-right: 5%;">
          <p style="font-size: 1em; color: rgb(78, 194, 136); font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em; font-weight: bold; margin-top: 0.2em;">Commenti Attuali</p>
          <p style="font-size: 350%; color: #4E69C2; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em; font-weight: bold; margin-top: 0.2em;">99.000</p>
        </div>

      </div>

      <div class="column">

        <div class="columnbox" style="margin-right: 5%;">
          <p style="font-size: 1em; color: rgb(78, 194, 136); font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em; font-weight: bold; margin-top: 0.2em;">Engagement Rate</p>
          <p style="font-size: 350%; color: #4E69C2; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em; font-weight: bold; margin-top: 0.2em;">99.000</p>
        </div>

      </div>

    </div>

    <!-- Here is where my problems finishes -->

    <div class="divs">

      <h1 style="color:white; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-bottom: 0; padding-bottom: 0.2em">Entra nell'Area Personale!</h1>

      <p style="font-size: 1.4em; color: white; line-height: 150%;  font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; margin-top: 0; padding-top: 0">Visita la tua Area personale cliccando qui.<br> Potrai tenere traccia dei tuoi risultati!
      </p>

      <div class="btn" style="background-color: #4E69C2; text-decoration: none; display: inline-block; border: 3px solid #4E69C2; border-radius: 7px; font-size: 1.4em; padding: 0.3em 1em; -webkit-font-smoothing: antialiased; color: #fff;"><a class="btn-link" href="https://app.moover.digital/analytics" rel="noopener noreferrer" style="text-decoration: none; color: #fff; font-family:Open Sans,Roboto,San Francisco,Helvetica,Arial,sans-serif; font-size: 0.8em; font-weight: 600; -webkit-font-smoothing: antialiased;"
          target="_blank">Visita la tua Area ►</a></div>

    </div>

  </div>

</body>

</html>

结果应该是一个响应行,在桌面上有 4 列对齐在一个唯一的行中。在移动设备上,它应该是一个垂直的行,如下面的屏幕截图所示:

enter image description here

不幸的是,这不是我的结果,我绝对需要一些帮助,因为在手机的 Gmail 应用程序中,这是我得到的:

enter image description here

最佳答案

几点:

  1. 除非您对一般的电子邮件编码有信心,否则不要在电子邮件中使用 flexbox。我已经调整了你的一些代码(将 flex:#%; 扩展为 flex:0 0 #%; 并添加了后备宽度)并注意到我修复了一些东西所以我不认为你从前面采取的实现正如您所期望的那样,end 在电子邮件客户端中工作
    对于不同的电子邮件,您需要包含一些怪癖和修复 你应该知道的客户。谷歌这个寻求帮助,不确定 特别是任何文章,因为我没有费心尝试穿鞋 将 Flexbox 加入我的电子邮件。但有些人确实做了一些 进行搜索,您会找到一些帮助。
  2. 在电子邮件中使用 div 也是如此。可以做到并且用途广泛 他们,但你需要知道如何让他们在 Outlook 中工作 桌面客户端等。仅供引用,您的电子邮件已完全损坏 Outlook,包括我在 Litmus 中看到的最新版本 展望2019.
    您可能不需要支持 Outlook,这很好,但最好知道。
  3. 投资测试平台。 Litmus 和 Email On Acid 是顶级工具。
    这样您就可以构建和测试并确保您的电子邮件在需要的地方正常工作。

总的来说,在将前端技术引入电子邮件时要非常谨慎。它们并非都有效,但社区中有一些人找到了制作 Flexbox、CSS Grid 和其他一些流行的前端技术的方法,在电子邮件中工作,所以做一些研究,你就会有一个指南可以遵循。

就我个人而言,我认为没有必要使用像这样的最新技术。在大多数情况下,使用良好的旧表结构是可行的。
别误会我的意思,我很享受乐趣并测试最新的创新并为了乐趣而构建东西,但我总是回到那句老话“如果它没有坏,就不要修理它”。
电子邮件代码并不漂亮,也不完美,但它适用于 99% 的设计,个人更喜欢实现 Flexbox 等花哨的技术。

永远记住,您要使用易于维护的技术。您不希望每次尝试更新时都遇到此类问题。这非常耗时,而且当您只想发送电子邮件时可能会令人沮丧。

不过,我希望您能找到解决方案。通过某人帮助您实现 Flexbox,在电子邮件中查找有关执行此操作的博客文章,或者通过从头开始使用您更熟悉/得到更好支持并且更容易为您调试的代码。

关于html - HTML 电子邮件中的响应框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56392964/

相关文章:

javascript - 旋转的 HTML 元素 Angular 的 XY 坐标

linux - 如何从 Linux 发送文件到电子邮件?

HTML 表格(并排)不适合超大屏幕

jquery - 如何隐藏特定的 div 标签

html - 如果输入聚焦,iOS7 Safari 布局会因方向变化而中断

javascript - 尝试将工作表行数据发送到 GmailApp 时缺少变量名称; Javascript/Google 应用程序脚本

php - 在 Drupal 中重新通知用户帐户

html - 在低分辨率下将带有标题的 Logo 居中

html - 全部大写 在 Firefox 的下拉列表中选择选项值

css - Div 目标/主动过渡