简体   繁体   English

尝试使用Zurb Foundation使电子邮件在响应列点处折叠

[英]Trying to get email to collapse at responsive column points using Zurb Foundation

I'm trying to make this email responsive on both mobile and desktop. 我正在尝试使此电子邮件在移动设备和台式机上都能响应。 When I test this on Gmail mobile app the email does not collapse. 当我在Gmail移动应用上对此进行测试时,电子邮件不会折叠。 The columns hold the 6 by 6 grid instead of forming into full with 12 grids each. 这些列保留6 x 6的网格,而不是形成完整的12网格。 Can anyone help me figure out what the issue is? 谁能帮助我找出问题所在? I've already inlined my CSS using Zurb inliner. 我已经使用Zurb inliner内联了CSS。 But the issue with the grids not collapsing is still there. 但是网格不崩溃的问题仍然存在。

Also can anyone let me know of an email tester they would recommend to test responsive emails during development. 任何人也可以让我知道他们建议在开发过程中测试响应式电子邮件的电子邮件测试器。

Here is a link to the email template on Codepen 这是Codepen上电子邮件模板的链接

http://codepen.io/anon/pen/JEBVWK http://codepen.io/anon/pen/JEBVWK

Below is an example of one of the columns that should be 12 column width when on small and 6 by 6 column when on large, but remains 2 x 6 columns side by side even in Gmail app 以下是其中一列的示例,该列在较小的情况下应为12列宽,在较大的情况下应为6 x 6列,但即使在Gmail应用程序中也应并排2 x 6列

<table class="row" style="border-spacing: 0; border-collapse: collapse; vertical-align: top; text-align: left; width: 100%; position: relative; display: table; padding: 0;">
    <tbody>
        <tr align="left" style="vertical-align: top; text-align: left; padding: 0;">
            <th align="left" class="small-12 large-6 columns" style="width: 274px; color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-weight: normal; text-align: left; line-height: 1.3; font-size: 16px; margin: 0 auto; padding: 0 8px 16px 16px;">
                <ul class="disc">
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut sodales sapien aliquam arcu egestas dignissim. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut sodales</li>
                </ul>
                <table style="border-spacing: 0; border-collapse: collapse; vertical-align: top; text-align: left; width: 100%; padding: 0;">
                    <tr align="left" style="vertical-align: top; text-align: left; padding: 0;">
                        <td></td>
                    </tr>
                </table>
            </th>
            <th align="left" class="small-12 large-6 columns last" style="width: 274px; color: #0a0a0a; font-family: Helvetica, Arial, sans-serif; font-weight: normal; text-align: left; line-height: 1.3; font-size: 16px; margin: 0 auto; padding: 0 16px 16px 8px;">
                <ul class="disc">
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut sodales sapien aliquam arcu egestas dignissim.</li>
                </ul>
                <table style="border-spacing: 0; border-collapse: collapse; vertical-align: top; text-align: left; width: 100%; padding: 0;">
                    <tr align="left" style="vertical-align: top; text-align: left; padding: 0;">
                        <td></td>
                    </tr>
                </table>
            </th>
        </tr>
    </tbody>
</table>

I have found the Zurb template to be annoying as well. 我发现Zurb模板也很烦人。 The template you are using was built pre-hybrid period. 您使用的模板是在预混合期间构建的。 The code is heavily dependent on media queries which will only work on iOS and Android 4.4 and below. 该代码严重依赖于媒体查询,而媒体查询仅适用于iOS和Android 4.4及以下版本。 Try the hybrid method of coding. 尝试混合编码方法。 If you haven't heard of hybrid, it's the only method that allows all devices to show a responsive version of an email (even Gmail, Gmail app and Samsung devices). 如果您还没有听说过混合动力,那么它是唯一一种允许所有设备显示电子邮件的响应版本的方法(甚至包括Gmail,Gmail应用程序和Samsung设备)。

I wrote a step by step method (originally in SO Documentation, now shown below) that you can use to build your own template in no time. 我写了一个逐步的方法(最初在SO Documentation中,现在显示在下面),您可以立即使用它来构建自己的模板。 You can use inliner websites online to inline you CSS if you have them in your header. 如果标题中包含CSS,则可以在线使用inliner网站内联CSS。 Please let me know if you need my help in creating a full template in any way. 如果您需要我的帮助以任何方式创建完整的模板,请告诉我。


Coding method used: Hybrid/Spongy 编码方式:混合/海绵

It has been forever a myth that div's can not be used in emails. div不能在电子邮件中使用一直是一个神话。 There are email clients (unlike outlook) that can render div's properly. 有一些电子邮件客户端(与Outlook不同)可以正确显示div。 The example below will illustrate how an email can be coded that will work on Gmail app (with updates not rolled out yet), Samsung device's and other email clients that don't read media queries. 下面的示例将说明如何编码可在Gmail应用程序(尚未推出更新),三星设备的和其他不读取媒体查询的电子邮件客户端上使用的电子邮件。

Introducing Outlook conditional statements 介绍Outlook条件语句

Outlook conditional statements are very useful when it come to rendering emails or showing something specific like fall backs for outlook. 当涉及到呈现电子邮件或显示特定的东西(例如Outlook后备)时,Outlook条件语句非常有用。

<!--[if (gte mso 9)|(IE)]>
<![endif]-->

The above code reads if greater than microsoft outlook 9 or IE 如果大于Microsoft Outlook 9或IE,则读取以上代码

Outlook 2000 - Version 9
Outlook 2002 - Version 10
Outlook 2003 - Version 11
Outlook 2007 - Version 12
Outlook 2010 - Version 14
Outlook 2013 - Version 15

Versions for conditional statements listed. 列出了条件语句的版本。

Starting a hybrid email template 启动混合电子邮件模板

Each step has been explained in a way that it should be easy for anyone with basic HTML knowledge to understand. 每个步骤的解释方式都应使具有基本HTML知识的任何人都易于理解。

First we start with a wrapper table which will span all the way across the screen and with a class of container. 首先,我们从一个包装器表开始,该表将遍历整个屏幕并使用一类容器。

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tbody>
    <tr>
      <td>[CONTENT GOES HERE]</td>
    </tr>
  </tbody>
</table>

After that we add in a media query for email clients that dont read max width but read the CSS in the header. 之后,我们添加一个针对电子邮件客户端的媒体查询,该电子邮件客户端不读取最大宽度,但读取标头中的CSS。 The media query will be targeting all screens and showing the container at 700 pixels width. 媒体查询将定位到所有屏幕,并以700像素的宽度显示容器。

@media only screen and (max-width : 700px) {
.container{width:700px;}
}

Next we add an outlook conditional statement that keeps the table (with class container) to be at a width of 700 pixels. 接下来,我们添加一个Outlook条件语句,该语句使表(带有类容器)的宽度保持在700像素。

<!--[if (gte mso 9)|(IE)]>
    <table width="700" align="center" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td align="left" valign="top" width="700">
    <![endif]-->

        <table class="container" width="100%" border="0" cellspacing="0" cellpadding="0" style="width: 100%; max-width: 700px;">
              <tbody>
                <tr>
                  <td valign="top" bgcolor="#FFFFFF" style="padding:0px;text-align: center; vertical-align: top; font-size: 0px;">[CONTENT GOES HERE]</td>
                </tr>
              </tbody>
        </table>

    <!--[if (gte mso 9)|(IE)]>
            </td>
        </tr>
    </table>
<![endif]-->

The above code should now hold your template in outlook at 700px wide. 上面的代码现在应该使模板在Outlook中的宽度为700px。

Now for the columns. 现在为列。 Below code will create two equal columns on the template both at 350px wide. 下面的代码将在模板上创建两个相等的列,两个列的宽度均为350px。

<!--[if (gte mso 9)|(IE)]>
<table width="700" align="center" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td align="left" valign="top" width="350">
<![endif]-->
<div style="width: 350px; display: inline-block; vertical-align: top;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tbody>
    <tr>
      <td>[COLUMN CONTENT HERE]</td>
    </tr>
  </tbody>
</table>
</div>

<!--[if (gte mso 9)|(IE)]>
</td><td align="left" valign="top" width="300">
<![endif]-->

<div style="width: 350px; display: inline-block; vertical-align: top;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tbody>
    <tr>
      <td>[COLUMN CONTENT HERE]</td>
    </tr>
  </tbody>
</table>
</div>

 <!--[if (gte mso 9)|(IE)]>
        </td>
    </tr>
</table>
<![endif]-->

After this the limit is only your imagination or the designer. 在此之后,限制只是您的想象力或设计师。 When designs are done it is important to be involved in the wire framing stage so there are no suprises once the design is in coding stage. 完成设计后,重要的是要参与布线框架阶段,因此一旦设计进入编码阶段就不会感到意外。

Note: 注意:

  • Retina images will need images set at the element level not on its style 视网膜图像将需要在元素级别而不是其样式上设置图像
  • You can still choose to do in-line CSS or you can choose to CSS in head only if all your clients support CSS in the head. 您仍然可以选择做内联CSS,或者仅所有客户端都支持CSS的情况下才选择CSS。

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

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