【问题标题】:HTML email text not displaying correctly in Gmail MobileHTML 电子邮件文本在 Gmail 移动版中未正确显示
【发布时间】:2016-11-05 04:54:42
【问题描述】:

我终于可以让我的电子邮件在所有客户端中看起来都很棒了……除了 Gmail 移动版。具体来说,它将我的导航栏链接和页脚栏链接(它们是表格)向左推,而不是居中。

有什么建议吗?

导航条码:

<td style="font-family:'Helvetica',
monospace;font-size:12px;line-height:15px;color:#FFFFFF;text-align:center;text-decoration:none;white-space:nowrap;"><a moz-do-not-send="true" href="https://partofthekult.com/collections/tees" target="_blank" style="font-family:'Helvetica',
monospace;font-size:15px;line-height:15px;color:#FFFFFF;text-align:center;text-decoration:none;white-space:nowrap;">TEES
                                 </a></td>
                            <td width="0">
                              <table align="center" border="0" cellpadding="0" cellspacing="0" width="20">
                                <tbody>
                                  <tr>
                                  </tr>
                                </tbody>
                              </table>
                            </td>
                            <td style="font-family:'Helvetica',
monospace;font-size:12px;line-height:15px;color:#FFFFFF;text-align:center;text-decoration:none;white-space:nowrap;"><a moz-do-not-send="true" href="https://partofthekult.com/collections/tanks" target="_blank" style="font-family:'Helvetica',
monospace;font-size:15px;line-height:15px;color:#FFFFFF;text-align:center;text-decoration:none;white-space:nowrap;">TANKS</a></td>
                            <td class="ecxh" width="0">
                              <table align="center" border="0" cellpadding="0" cellspacing="0" width="20">
                                <tbody>
                                  <tr>
                                  </tr>
                                </tbody>
                              </table>
                            </td>
                            <td class="ecxh" style="font-family:'Helvetica',
monospace;font-size:12px;line-height:15px;color:#FFFFFF;text-align:center;text-decoration:none;white-space:nowrap;"><a moz-do-not-send="true" href="https://partofthekult.com/collections/accessories" target="_blank" style="font-family:'Helvetica',
monospace;font-size:15px;line-height:15px;color:#FFFFFF;text-align:center;text-decoration:none;white-space:nowrap;">ACCESSORIES
                                 </a></td>
                            <td class="ecxh" width="0">
                              <table align="center" border="0" cellpadding="0" cellspacing="0" width="20">
                                <tbody>
                                  <tr>
                                  </tr>
                                </tbody>
                              </table>
                            </td>
                            <td class="ecxh" style="font-family:'Helvetica',
monospace;font-size:12px;line-height:15px;color:#FFFFFF;text-align:center;text-decoration:none;white-space:nowrap;"><a moz-do-not-send="true" href="https://partofthekult.com/collections/sale" target="_blank" style="font-family:'Helvetica',
monospace;font-size:15px;line-height:15px;color:#FFFFFF;text-align:center;text-decoration:none;white-space:nowrap;">SALE</a></td>
                            <td class="ecxh" width="0">
                              <table align="center" border="0" cellpadding="0" cellspacing="0" width="20">
                                <tbody>
                                  <tr>
                                  </tr>
                                </tbody>
                              </table>
                            </td>
                          </tr>
                        </tbody>
                      </table>
                    </td>
                  </tr>
                </tbody>
              </table>

而我的页脚与此类似,除了使用图像链接而不是文本。

【问题讨论】:

    标签: javascript jquery html css email


    【解决方案1】:

    查看您的代码后,您似乎已使用align="center" 属性将表格居中。我建议使用 CSS 而不是 HTML 属性。您可以使用margin:0 auto; CSS 属性在其父容器中将表格居中。

    请看下面更新的代码:

    <table class="ecxw320" align="center" border="0" cellpadding="0" cellspacing="0" width="640">
      <tbody>
        <tr bgcolor="#000000">
          <td height="50">
            <!--Use margin:0 auto; to center a table within it's parent container-->
            <table style="margin:0 auto;" border="0" cellpadding="0" cellspacing="0">
              <tbody>
                <tr>
                  <td>
                    <table align="center" border="0" cellpadding="0" cellspacing="0">
                      <tbody>
                        <tr>
                          <td width="20">
    
                          </td>
                        </tr>
                      </tbody>
                    </table>
                  </td>
    
                  <td style="font-family:'Helvetica',
    monospace;font-size:12px;line-height:15px;color:#FFFFFF;text-align:center;text-decoration:none;display:block;white-space:nowrap;"><a moz-do-not-send="true" href="https://partofthekult.com/collections/tees" target="_blank" style="font-family:'Helvetica',
    monospace;font-size:15px;line-height:15px;color:#FFFFFF;text-align:center;text-decoration:none;display:block;white-space:nowrap;">TEES
                                     </a>
                  </td>
                  <td width="0">
                    <table align="center" border="0" cellpadding="0" cellspacing="0" width="20">
                      <tbody>
                        <tr>
                        </tr>
                      </tbody>
                    </table>
                  </td>
                  <td style="font-family:'Helvetica',
    monospace;font-size:12px;line-height:15px;color:#FFFFFF;text-align:center;text-decoration:none;display:block;white-space:nowrap;"><a moz-do-not-send="true" href="https://partofthekult.com/collections/tanks" target="_blank" style="font-family:'Helvetica',
    monospace;font-size:15px;line-height:15px;color:#FFFFFF;text-align:center;text-decoration:none;display:block;white-space:nowrap;">TANKS</a>
                  </td>
                  <td class="ecxh" width="0">
                    <table align="center" border="0" cellpadding="0" cellspacing="0" width="20">
                      <tbody>
                        <tr>
                        </tr>
                      </tbody>
                    </table>
                  </td>
                  <td class="ecxh" style="font-family:'Helvetica',
    monospace;font-size:12px;line-height:15px;color:#FFFFFF;text-align:center;text-decoration:none;display:block;white-space:nowrap;"><a moz-do-not-send="true" href="https://partofthekult.com/collections/accessories" target="_blank" style="font-family:'Helvetica',
    monospace;font-size:15px;line-height:15px;color:#FFFFFF;text-align:center;text-decoration:none;display:block;white-space:nowrap;">ACCESSORIES
                                     </a>
                  </td>
                  <td class="ecxh" width="0">
                    <table align="center" border="0" cellpadding="0" cellspacing="0" width="20">
                      <tbody>
                        <tr>
                        </tr>
                      </tbody>
                    </table>
                  </td>
                  <td class="ecxh" style="font-family:'Helvetica',
    monospace;font-size:12px;line-height:15px;color:#FFFFFF;text-align:center;text-decoration:none;display:block;white-space:nowrap;"><a moz-do-not-send="true" href="https://partofthekult.com/collections/sale" target="_blank" style="font-family:'Helvetica',
    monospace;font-size:15px;line-height:15px;color:#FFFFFF;text-align:center;text-decoration:none;display:block;white-space:nowrap;">SALE</a>
                  </td>
                  <td class="ecxh" width="0">
                    <table align="center" border="0" cellpadding="0" cellspacing="0" width="20">
                      <tbody>
                        <tr>
                        </tr>
                      </tbody>
                    </table>
                  </td>
                </tr>
              </tbody>
            </table>
          </td>
        </tr>
      </tbody>
    </table>

    【讨论】:

    • 抱歉,我的问题中没有包含完整的代码,也没有包含当前效果的截图。以下是完整代码:[link] (paste.ofcode.org/JQS3ykcP7aB9GsZ82Jcu2g) 以下是它在 Gmail 应用中的显示截图:[link] (cdn.shopify.com/s/files/1/1041/0020/files/…)
    • @S.White 只是想知道您是否在内表上尝试过margin:0 auto;。另外我建议在所有表格上使用它而不是 align="center" 属性,你想居中。请参阅上面的更新答案。
    • 我尝试了新代码,它完全解决了 Gmail 上奇怪的右侧边距问题,并且在其他客户端上也很好。我也为页脚栏实现了相同的代码部分,现在可以完美运行。添加这些 sn-ps 后,我唯一的问题是 Gmail 应用程序中的栏看起来很薄——用一点填充解决了它。感谢您前来救援! :-)
    • @S.White 很高兴它有帮助。
    猜你喜欢
    • 1970-01-01
    • 2020-04-09
    • 1970-01-01
    • 2011-04-10
    • 2013-12-16
    • 2013-06-06
    • 1970-01-01
    • 2013-02-05
    • 1970-01-01
    相关资源
    最近更新 更多