【问题标题】:Horizontal Scroll on HTML Tables in Gmail for Android Not WorkingAndroid版Gmail中HTML表格的水平滚动不起作用
【发布时间】:2020-11-08 04:53:49
【问题描述】:

因此,我尝试发送包含宽表的 HTML 电子邮件(如果需要,使用 PHP),并将其格式化为 Android 和 iOS 版 Gmail 中可水平滚动的格式。无论如何,无论我做什么,我都无法在 Android 版 Gmail 应用程序中显示水平滚动条,尽管它似乎可以在网络版 Gmail 中使用。我已经用表格宽度 100% 尝试过这个,没有表格宽度和最小宽度,没有任何效果。我也尝试过使用 overflow-x: auto 而不是 scroll。

Android 版 Gmail 只会显示到某一列,然后,如果您向右滑动滚动,它会将您带到上一封电子邮件。我注意到的是,如果我进入我的 Android 版 Gmail 设置并禁用“自动调整邮件”,它可以解决问题。不幸的是,这是默认设置,我不能指望我的所有读者都禁用它(有没有办法在我的 html 中禁用它?)。

这是我的电子邮件 html。

<html>
    <head></head>
    <body>
        <div style="overflow-x: scroll;">
            <table style="width: 100%;">
                <tr>
                    <th>Article</th>
                    <th>Entrance</th>
                    <th>Page Views</th>
                    <th>Author</th>
                    <th>Images in Article</th>
                    <th>Links in Article</th>
                    <th>Links to Article</th>
                    <th>Meta Title</th>
                    <th>Google Referrers</th>
                    <th>AMP Traffic</th>
                    <th>Users</th>
                </tr>
                <tr>
                    <td>How to Scroll in Gmail</td>
                    <td>500,000</td>
                    <td>700,000</td>
                    <td>John Smith</td>
                    <td>25</td>
                    <td>200</td>
                    <td>How to Scroll in Gmail: a Comprehensive Guide</td>
                    <td>2,000,000</td>
                    <td>3,000,000</td>
                    <td>100,000,000</td>
                </tr>
            </table>
        </div>
    </body>
</html>

有什么想法吗?或者是不可能在 Gmail 应用程序中显示水平滚动条,因为 Google 想要它的滑动正确的东西?

【问题讨论】:

  • 使用meta标签并使用媒​​体查询。它会起作用的。
  • 我有类似的问题,滚动添加到表格数据 div 中,在桌面上运行良好,但在移动 gmail 应用程序上出现问题,因为它会滑动到下一封/上一封电子邮件。

标签: css gmail html-email


【解决方案1】:

对于像数据表这样重要的东西,我强烈建议不要水平滚动。如您所见,Gmail 移动应用的侧滚动/滑动默认做法是切换电子邮件。

ActionRocket ran a test 几年前有他们自己的时事通讯,实际上支持它的电子邮件客户端是 Apple Mail(Mac 和 iOS)、Outlook for Mac 和 Gmail Webmail。覆盖范围实际上很小,您需要为您要发送到的其他电子邮件客户端提供可靠的修复。

我建议对您的表格采用不同的方法,例如将列标题和列内容堆叠在一起,如下所示 (also in Codepen):

<style type="text/css">
  @media only screen and (max-width:1300px) {
    .row { display:block!important; width:100%!important; }
  }
</style>
<div style="overflow-x: scroll;">
  <table style="width: 100%;">
    <tr>
      <th>Article</th>
      <th>Entrance</th>
      <th>Page Views</th>
      <th>Author</th>
      <th>Images in Article</th>
      <th>Links in Article</th>
      <th>Links to Article</th>
      <th>Meta Title</th>
      <th>Google Referrers</th>
      <th>AMP Traffic</th>
      <th>Users</th>
    </tr>
    <tr>
      <td>How to Scroll in Gmail</td>
      <td>500,000</td>
      <td>700,000</td>
      <td>John Smith</td>
      <td>25</td>
      <td>200</td>
      <td>How to Scroll in Gmail: a Comprehensive Guide</td>
      <td>2,000,000</td>
      <td>3,000,000</td>
      <td>100,000,000</td>
    </tr>
  </table>
</div>

<br>
<br>
<br>
<br>
<br>
<br>

<table border="0" cellpadding="0" cellspacing="0" style="width:100%;" role="presentation">
  <tr>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;" colspan="2">
            Article
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            How to Scroll in Gmail
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Entrance
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            500,000
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Page Views
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            700,000
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Author
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            John Smith
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Images in Article
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            John Smith
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Links in Article
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            25
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Links to Article
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            200
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Meta Title
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            How to Scroll in Gmail: a Comprehensive Guide
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Google Referrers
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            2,000,000
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            AMP Traffic
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            3,000,000
          </td>
        </tr>
      </table>
    </th>
    <th class="row" valign="top" style="font-weight:400;">
      <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
        <tr>
          <th style="background:#16818D; color:#fff; padding:10px 0;">
            Users
          </th>
        </tr>
        <tr>
          <td style="background:#eeeeee; color:#333; padding:10px 0;">
            100,000,000
          </td>
        </tr>
      </table>
    </th>
  </tr>
</table>

显然,我已经将另一个项目的样式留在了那里,但它让您了解了潜力。这也是更多的代码,但对于小屏幕来说,这是一个很好的替代方案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-23
    • 2013-11-11
    • 2019-10-09
    • 2017-01-07
    • 1970-01-01
    • 2021-11-18
    • 1970-01-01
    相关资源
    最近更新 更多