gmail 应用中 HTML 电子邮件中的不需要的行

Unwanted lines in HTML email in gmail app

我正在为电子邮件流创建一堆电子邮件。出于某种原因我找不到,当我在 GMAIL APP 中测试电子邮件时,在 1px 高度处有一些不需要的灰线。

我只是不知道为什么他们在那里。它似乎只在 GMAIL APP 中 - 我正在使用 litmus.com

进行测试

电子邮件的HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <!--[if !mso]><!-->
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <!--<![endif]-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vores 5 bedste råd inden boligkøbet</title>
    <meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
    <!--[if (gte mso 9)|(IE)]>
    <style type="text/css">
        table {border-collapse: collapse;}
    </style>
    <![endif]-->
    <!--[if mso]>
            <style> body,table tr,table td,a, span,table.MsoNormalTable {  font-family:Arial, Helvetica, sans-serif !important;  }
    </style>
        <!--<![endif]-->
    <style type="text/css">
        @media screen and (max-width: 525px) {
            h1 {
                font-size: 30px !important;
            }
        }
    </style>
</head>
<body bgcolor="#3d6e9c" style="padding: 0; margin: 0;">

    <div style="background-color:#3d6e9c;">
        <!--[if gte mso 9]>
        <v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t">
          <v:fill type="tile" src="http://naborapporten.its-umbraco.dk/emails/bg.jpg" color="#3d6e9c"/>
        </v:background>r
        <![endif]-->
        <table height="100%" width="100%" cellpadding="0" cellspacing="0" border="1">
            <tr>
                <td valign="top" align="left" background="http://naborapporten.its-umbraco.dk/emails/bg.jpg">

                    <center>
                        <!--[if (gte mso 9)|(IE)]><table width="650" align="center" cellpadding="0" cellspacing="0" border="0"><tr><td><![endif]-->
                        <table cellspacing="0" cellpadding="0" border="0" style="border: none; border-collapse: collapse; width: 100%;">
                            <tr>
                                <td background="http://naborapporten.its-umbraco.dk/emails/bg.jpg" align="center" style="font-family: Arial; padding-top: 100px; padding-bottom: 100px; padding-left: 15px; padding-right: 15px;">
                                    <table border="0" align="center" cellspacing="0" cellpadding="0" style="width: 100%; max-width: 650px; border-collapse: collapse; border: none; ">
                                        <tr>
                                            <td height="43" valign="bottom"><img src="http://naborapporten.its-umbraco.dk/emails/top.png" valign="bottom" style="font-family: Arial; max-width: 650px; width: 100%; height: auto; vertical-align: bottom; border-collapse: collapse;"></td>
                                        </tr>
                                        <tr>
                                            <td align="center" bgcolor="#ffffff" style="font-family: Arial; padding-left: 15px; padding-right: 15px; padding-top: 45px; padding-bottom: 45px; border-collapse: collapse;">
                                                <h1 style="color: #707986; font-size: 45px; margin-bottom: 0; mso-line-height-rule: exactly; line-height: 90%;"><b><b>Din Naborapport™</b></b></h1>

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

                                                <table cellpadding="0" cellspacing="0" border="0" style="border-collapse: collapse; max-width: 470px; width: 100%;">
                                                    <tr>
                                                        <td align="center" style="color: #707986; font-size: 18px; padding-top: 45px; border-collapse: collapse;"><b>@Model.FullAddress</b></td>
                                                    </tr>
                                                </table>

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


                                            </td>
                                        </tr>

                                        <tr>

                                            <td align="center" bgcolor="#ffffff">

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

                                                <table border="0" cellspacing="0" cellpadding="0" align="center" style="max-width: 470px; width: 100%; border-collapse: collapse;">
                                                    <tr>
                                                        <td align="center" bgcolor="#ffffff" valign="middle" style="padding-top: 45px; padding-bottom: 45px;  padding-left: 15px; padding-right: 15px;"><a href="@Model.NeighbourReportUrl"><img src="http://naborapporten.its-umbraco.dk/gfx/email/knap_til_naborapport.png" border="0" style="border: none; max-width: 100%; height: auto;"></a></td>
                                                    </tr>

                                                    <tr>
                                                        <td align="center" bgcolor="#ffffff">

                                                            <table cellpadding="0" cellspacing="0" border="0">
                                                                <tr>
                                                                    <td align="center" bgcolor="#ffffff" style="font-family: Arial; max-width: 470px; width: 100%;  padding-left: 15px; padding-right: 15px;">
                                                                        <h2 style="color: #1fbba7; font-size: 30px; font-weight: bold;">Naborapporten giver dig et unikt indblik i nabolaget</h2>

                                                                        <table>
                                                                            <tr>
                                                                                <td align="center" valign="middle" style="font-size: 18px; color: #5d6573; ">
                                                                                    <p><b>Hvilke typer er dine naboer?</b></p>

                                                                                    <p><b>Hvad er afstanden til skole, indkøb og transport?</b></p>

                                                                                    <p><b>Hvad beskæftiger dine naboer sig med til dagligt?</b></p>

                                                                                    <b>Hvad er prisudviklingen på boliger i området?</b>
                                                                                </td>
                                                                            </tr>
                                                                        </table>

                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>

                                                </table>

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


                                            </td>
                                        </tr>
                                        <tr>
                                            <td valign="middle" align="center" bgcolor="#ffffff" style="font-family: Arial; padding-top: 45px; padding-left: 15px; padding-right: 15px; border-collapse: collapse;">
                                                <span style="color: #1fbba7; font-size: 18px; font-weight: bold;">Få gode råd til huskøbet på vores boligunivers</span>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="center" bgcolor="#ffffff" style="padding-top: 45px; padding-bottom: 45px; padding-left: 15px; padding-right: 15px; border-collapse: collapse;">
                                                <a href="#"><img src="http://naborapporten.its-umbraco.dk/emails/kvittering/knap_book.png" style="border: none; max-width: 100%; height: auto;" /></a>
                                            </td>
                                        </tr>

                                        <tr>
                                            <td bgcolor="#eeeeee" align="center" valign="middle" style="padding-top: 45px; border-collapse: collapse;">
                                                <img src="http://naborapporten.its-umbraco.dk/emails/logo.png">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td valign="top" style="border-collapse: collapse;"><img src="http://naborapporten.its-umbraco.dk/emails/bund.png" valign="top" alt="" style="max-width: 100%; height: auto;"></td>
                                        </tr>
                                        <tr>
                                            <td height="92" align="center" valign="middle" style="border-collapse: collapse;"><a href="#" style="color: #ffffff !important; text-decoration: none; color: #ffffff; font-family: Arial; font-size: 18px;"><b>Afmeld</b></a></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                        <!--[if (gte mso 9)|(IE)]></td></tr></table><![endif]-->
                    </center>

                </td>
            </tr>
        </table>
    </div>

</body>
</html>

将table边框设为“0”

<table height="100%" width="100%" cellpadding="0" cellspacing="0" border="0">

希望对您有所帮助!

按照 Gokul Maha 的建议,我将第 35 行的 border="1" 更改为 border="0"。但奇怪的是,单个实例会导致出现三个水平边框。

关于 Litmus 中的电子邮件预览,由于他们在收件箱中打开电子邮件并创建屏幕截图的方式,它们并不总是 100% 准确。如果可以的话,我建议使用 Gmail 应用程序的实际副本对此进行测试。结果可能不同。 Litmus 节省了大量时间,但对于小细节,了解它在实际设备上的外观总是好的 运行 实际的电子邮件应用程序。

我最近创建了一个具有相同问题的类似邮件。在我的例子中,我试图给整个邮件加上边框,效果很好,但它在 img 和其他一些对象周围创建了小边框。

为了解决这个问题,我在 table 之后的每个第一个 td 中添加了 style="border: none;",并带有边框。这为我修好了。

也可以尝试将边框放在 td 上。如果某些 Outlook 版本位于 table.

上,则边框似乎不会出现

如果您根本不需要边框,您可以将第 35 行中的 border="1" 设置为 0。

在我看来,您的背景颜色正在渗透。这是 iOS 设备和其他一些应用程序的常见问题。为什么要在正文和第一个 div 标签上设置背景颜色?

您好,我通过将 bgcolor="#ffffff" style="background-color:#ffffff;" 放在 body 标签和 td 标签以及每个 table 标签中来解决这个问题。 gmail 应用程序中的所有灰线都消失了。