Android版Gmail中HTML表格的水平滚动不起作用



所以我试图发送一封HTML电子邮件(如果重要的话,使用PHP(,里面有宽表,并在Android和iOS的Gmail中设置为水平滚动格式。不管怎样,无论我做什么,我都无法在安卓版的Gmail应用程序中显示水平滚动条,尽管它似乎在网络上的Gmail中有效。我试过用100%的表宽,没有表宽和最小宽度,但什么都不起作用。我也试过用overflow-x:auto代替滚动。

安卓版的Gmail只显示在某一列,然后,如果你向右滑动滚动,它会带你进入上一封电子邮件。我注意到的是,如果我进入我的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应用程序中显示水平滚动条吗?

对于像数据表这样重要的东西,我强烈建议不要进行水平滚动。Gmail移动应用程序的默认做法是切换电子邮件,正如你所看到的。

几年前,ActionRocket用他们自己的时事通讯对此进行了测试,真正支持它的电子邮件客户端是Apple Mail(Mac和iOS(、Outlook for Mac和Gmail Webmail。覆盖范围实际上很小,你需要对你要发送到的其他电子邮件客户端进行可靠的修复。

我建议对您的表采用不同的方法,例如将列标题和列内容堆叠在一个组中,如下所示(也在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>

很明显,我在那里留下了另一个项目的风格,但它让你了解了潜力。这是更多的代码,但对于较小的屏幕来说,这是一个很好的替代方案。

最新更新