【问题标题】:How to make responsive email work with yahoo mobile app?如何使响应式电子邮件与雅虎移动应用程序一起使用?
【发布时间】:2017-02-18 23:24:52
【问题描述】:

我创建了一个电子邮件模板,该模板经过测试可以在 gmail/yahoo/outlook 等桌面客户端上正常工作,并且还测试了移动 gmail 应用程序上的正确响应行为。我正在使用 Android/Galaxy S4。

响应式样式在雅虎移动应用上无效。事实上,它不是从“样式”中读取 CSS 规则。不过,桌面 chrome 设置为移动视图(使用 Inspect -> 切换设备工具栏)并登录到 yahoo 邮件会显示正在阅读响应式样式的电子邮件。

问题:雅虎移动应用不支持响应吗?或者,它是否特别需要额外的 hack?


更新: 我尝试将 CSS 样式从头部移动到身体。然后它读取样式。但是在正文中添加样式可能不是一个好主意,gmail 移动应用程序现在会忽略它。


这是我使用的电子邮件代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Sample Page</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="x-apple-disable-message-reformatting">
    <style>
        body {
            mso-line-height-rule:exactly;
            -ms-text-size-adjust:100%;
            -webkit-text-size-adjust:100%}
        table, td {
            mso-table-lspace: 0pt;
            mso-table-rspace: 0pt}
        table {
            border-collapse: collapse;
            border-spacing: 0;margin: 0 auto}
        img, a img {
            border:0 none;
            height: auto;
            line-height: 100%;
            outline: none;
            -ms-interpolation-mode: bicubic}
        a[x-apple-data-detectors] {
            color: inherit !important;
            text-decoration: none !important;
            font-size: inherit !important;
            font-family: inherit !important;
            font-weight: inherit !important;
            line-height: inherit !important}
        .x-gmail-data-detectors, .x-gmail-data-detectors *, .aBn {
            border-bottom: 0 !important;
            cursor: default !important}
        .a6S {
            display:none !important;
            opacity:0.01 !important}
        img.g-img + div {
            display:none !important}
        .button-link {
            text-decoration: none !important}
        @media only screen and (min-device-width: 375px) and (max-device-width: 413px) {
            .ios-gm-fix {
                min-width: 375px !important;}
        }
    </style>
    <style>
        #email-container {
            border:1px solid #CCC;
            border-radius:3px;
            border-collapse:separate}
        .desktop-view {color:blue}
        .mobile-view {color:#444}
        @media only screen and (max-width: 480px) {
            #email-container-wrap {
                width:100% !important;
                padding:0 !important}
            #email-container {
                border:none;border-radius:0}
            .desktop-view {color:#444}
            .mobile-view {color:blue}
            #email-contents {
                padding:15px 22px !important;
                font-size:16px!important}
        }
    </style>
</head>
<body width="100%" bgcolor="#FFFFFF" style="margin:0 auto;padding:0;height:100%">
    <center style="width=100%;background=#ffffff">
    <table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#F0F0F0" class="ios-gm-fix" style="margin:0;width:100%;line-height:100%"><tbody>
        <tr>
            <td align="center" valign="top" width="100%" style="padding:0;margin:0;height:100%;width:100%">
                <div id="email-container-wrap" style="width:600px;max-width:600px;padding:25px 0;margin:0 auto">
                    <table role="presentation" border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#ffffff" id="email-container" style="background-color:#ffffff"><tbody>
                        <tr>
                            <td align="center" valign="top" width="100%" id="email-contents" style="font-family:arial,helvetica,sans-serif;font-size:13px;line-height:18px;color:#333333;padding:20px 35px">
                                <table role="presentation" border="0" cellspacing="0" cellpadding="0" width="100%"><tbody>
                                    <tr>
                                        <td align="center" valign="top" width="100%" id="email-header">
                                            <table  role="presentation" border="0" cellspacing="0" cellpadding="0" width="100%"><tbody>
                                                <tr>
                                                    <td align="left" valign="top" width="100%"></td>
                                                </tr>
                                            </tbody></table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center" valign="top" width="100%" id="email-body">
                                            <table  role="presentation" border="0" cellspacing="0" cellpadding="0" width="100%">
                                                <tbody>
                                                    <tr>
                                                        <td align="left" valign="top" width="100%">
                                                            <table role="presentation" border="0" cellspacing="0" cellpadding="0" width="100%"><tbody>
                                                                <tr>
                                                                    <td align="left" valign="top" width="100%" class="desktop-view" style="padding:3px 0 16px">
                                                                        <span>On Desktop, there will be a border and gray background on all sides.</span>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td align="left" valign="top" width="100%" class="mobile-view" style="padding:3px 0 16px">
                                                                        <span>On Mobile, the border and background will not exist.</span>
                                                                    </td>
                                                                </tr>
                                                            </tbody></table>
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center" valign="top" width="100%" id="email-footer">
                                            <table  role="presentation" border="0" cellspacing="0" cellpadding="0" width="100%"><tbody>
                                                <tr>
                                                    <td align="left" valign="top" width="100%">
                                                    </td>
                                                </tr>
                                            </tbody></table>
                                        </td>
                                    </tr>
                                </tbody></table>
                            </td>
                        </tr>
                    </tbody></table>
                </div>
            </td>
        </tr>
    </tbody></table>
    </center>
</body>
</html>

【问题讨论】:

  • 您可能想查看这个关于现代 HTML 电子邮件编码的教程系列:blog.edmdesigner.com/modern-html-email-tutorial 查看这个新的 Drop Calc 方法来创建响应式电子邮件模板。这种方法将帮助您编写同样适用于 Yahoo 的电子邮件。 blog.edmdesigner.com/…
  • @Ethan 你能发布你正在使用的代码,以便我们调试并找出发生了什么吗?
  • @TedGoas 是的,我会剪出一个小的测试版本,然后在这里发布。完成后会通知您。
  • @TedGoas 我已经更新了代码。

标签: email responsive-design newsletter yahoo-mail


【解决方案1】:

在 Android 上,Yahoo 仅支持 &lt;body&gt; 中的 &lt;style&gt; 标签,而不支持 &lt;head&gt; 中的标签。但是Gmail只支持&lt;head&gt;中的&lt;style&gt;标签,&lt;body&gt;中不支持。 C'est la vie!

由于我们只处理约 20 行代码(假设您的示例中是第二个 &lt;style&gt; 标记),您可以尝试复制此 &lt;style&gt; 标记,使其同时出现在 &lt;head&gt;&lt;body&gt; .我不确定这是否可行,但值得测试。

【讨论】:

  • 这确实是C'est la vie!是的,我已经开始复制了。 (我在代码中嵌入的
猜你喜欢
  • 2019-08-14
  • 1970-01-01
  • 2014-05-15
  • 1970-01-01
  • 1970-01-01
  • 2019-08-24
  • 1970-01-01
  • 2013-09-19
  • 1970-01-01
相关资源
最近更新 更多