【问题标题】:Html Email not reading media queries on MobileHtml 电子邮件未在移动设备上读取媒体查询
【发布时间】:2017-05-29 08:19:27
【问题描述】:

我对开发 HTML 电子邮件很陌生,但我在媒体查询方面遇到了问题。

这是正在发生的事情:当我完成电子邮件开发并调整屏幕大小以检查它是否响应时,它按计划工作并适应任何屏幕尺寸。但是,在使用 MailChimp 发送测试电子邮件以查看电子邮件是否真正响应后,我发现移动应用程序(例如 Outlook 和 Gmail)实际上并没有使电子邮件大小适应屏幕大小。

他们实际上使字体和图像更小,以便整个内容像笔记本电脑一样适合

有谁知道为什么会发生这种情况以及如何阻止它?

这是我的head 标签:

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>PROMONOTICIAS</title>

  <style type="text/css">
     /* Client-specific Styles */
     #outlook a {padding:0;} /* Force Outlook to provide a "view in browser" menu link. */

     body{width:100% !important; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%; margin:0; padding:0;}

     /* Prevent Webkit and Windows Mobile platforms from changing default font sizes, while not breaking desktop design. */
     .ExternalClass {width:100%;} /* Force Hotmail to display emails at full width */

     .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {line-height: 100%;} /* Force Hotmail to display normal line spacing.  More on that: http://www.emailonacid.com/forum/viewthread/43/ */

     #backgroundTable {margin:0; padding:0; width:100% !important; line-height: 100% !important;}

     img {outline:none; text-decoration:none;border:none; -ms-interpolation-mode: bicubic;}

     a img {border:none;}

     .image_fix {display:block;}

     p {margin: 0px 0px !important;}

     table td {border-collapse: collapse;}

     table { border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; }

     /*a {color: #e95353;text-decoration: none;text-decoration:none!important;}*/
     /*STYLES*/
     table[class=full] { width: 100%; clear: both; }

     /*################################################*/
     /*IPAD STYLES*/
     /*################################################*/

     @media only screen and (max-width: 640px) {
     a[href^="tel"], a[href^="sms"] {
     text-decoration: none;
     color: #ffffff; /* or whatever your want */
     pointer-events: none;
     cursor: default;
     }
     .mobile_link a[href^="tel"], .mobile_link a[href^="sms"] {
     text-decoration: default;
     color: #ffffff !important;
     pointer-events: auto;
     cursor: default;
     }
     table[class=devicewidth] {width: 440px!important;text-align:center!important;}
     table[class=devicewidthinner] {width: 420px!important;text-align:center!important;}
     table[class="sthide"]{display: none!important;}
     img[class="bigimage"]{width: 420px!important;height:219px!important;}
     img[class="col2img"]{width: 420px!important;height:258px!important;}
     img[class="image-banner"]{width: 440px!important;height:106px!important;}
     td[class="menu"]{text-align:center !important; padding: 0 0 10px 0 !important;}
     td[class="logo"]{padding:10px 0 5px 0!important;margin: 0 auto !important;}
     img[class="logo"]{padding:0!important;margin: 0 auto !important;}

     }
     /*##############################################*/
     /*IPHONE STYLES*/
     /*##############################################*/
     @media only screen and (max-width: 480px) {
     a[href^="tel"], a[href^="sms"] {
     text-decoration: none;
     color: #ffffff; /* or whatever your want */
     pointer-events: none;
     cursor: default;
     }
     .mobile_link a[href^="tel"], .mobile_link a[href^="sms"] {
     text-decoration: default;
     color: #ffffff !important; 
     pointer-events: auto;
     cursor: default;
     }
     td[class="mobile-title"]{font-size: 15px !important;}
     a[class="mobile-text"]{font-size: 16px !important;}
     td[class="mobile-disclaimer"]{font-size: 13px !important;}
     table[class=devicewidth] {width: 320px !important;text-align:center!important;}
     table[class=devicewidthinner] {width: 300px !important;text-align:center!important;}
     table[class="sthide"]{display: none!important;}
     img[class="bigimage"]{width: 300px !important;height:136px!important;}
     img[class="col2img"]{width: 300px !important;height:160px!important;}
     img[class="image-banner"]{width: 320px !important;height:68px!important;}

     }
  </style>

【问题讨论】:

    标签: html css email gmail


    【解决方案1】:

    发送 HTML 电子邮件可能很烦人,因为大多数客户端应用程序不支持所有 CSS 属性,有些甚至切断了&lt;head&gt;。感觉有点像在 1995 年创建网页。我认为媒体查询在大多数情况下都不起作用,因为它们只是被切断了!您必须使用内联 CSS 使其具有响应性(叹气!)。我知道,这并不酷,但它是创建与大多数客户端兼容的 HTML 邮件的最佳方式。您可能需要查看此页面以了解简要概述、可以使用的内容以及可能不可以使用的内容:

    https://www.campaignmonitor.com/css/

    【讨论】:

    • 您好,感谢您的回复。然而,我的问题不在于head和媒体查询,而在于手机。如果head 被切断,我的风格将根本不被遵守,我的电子邮件会因为屏幕更小而看起来一团糟。但是,我的问题是 Gmail 移动应用程序和 Outlook 移动应用程序(我尝试过的两个应用程序)使所有内容变得更小,以使我的电子邮件在桌面上看起来与在 iPhone 4 上完全相同。我只是不不明白为什么。
    • 这很有趣,听起来可能是一些视口问题?无论如何,我仍然建议编写内联样式,因为肯定有很多客户端不支持 header-css 定义。也许可以选择使用现有模板?这可以节省大量工作,因为编写 HTML 时事通讯模板可能令人难以置信的烦人;)
    • 是的,我最终使用了 Litmus 的一个免费模板并重写了整个电子邮件。我仍然不知道为什么会发生这种情况,但是使用该模板我完成了工作。谢谢你的帮助,先生!
    猜你喜欢
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 2022-11-16
    • 1970-01-01
    • 2021-04-28
    • 2013-12-18
    • 2014-12-25
    • 2012-10-02
    相关资源
    最近更新 更多