2017-02-18 74 views
0

我創建了一個電子郵件模板,該模板經過測試可以在桌面客戶端上正常工作,如Gmail/yahoo/outlook,並且還測試了移動Gmail應用上的正確響應行爲。我正在使用Android/Galaxy S4。如何使響應電子郵件與雅虎手機應用程序工作?

響應式樣式在雅虎手機應用上無效。事實上,它沒有從'style'中讀取CSS規則。儘管將桌面鑲嵌設置爲移動視圖(使用Inspect - >切換設備工具欄)並登錄到雅虎郵件,但顯示的是閱讀響應式樣式的電子郵件。

問:雅虎手機應用不支持響應能力嗎?或者,它是否特別需要額外的黑客?


更新: 我試着從頭到身移動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> 
+0

你可能想看看關於現代HTML電子郵件編碼本系列教程: http://blog.edmdesigner.com/modern-html-email-tutorial/ 看看這個新的投遞Calc的方法來創建響應電子郵件模板。這種方法將幫助您編寫在雅虎工作的電子郵件。 http://blog.edmdesigner.com/the-drop-calc-method-to-create-responsive-html-emails/ –

+0

@Ehan你可以發佈你正在使用的代碼,所以我們可以調試並找出什麼是繼續? –

+0

@TedGoas是的,我會剪出一個小測試版本,並會在這裏發佈。一旦完成就會通知你。 – Ethan

回答

2

在Android上,雅虎只支持在<body><style>標籤,而不是在<head>。但Gmail僅支持<head>中的<style>標記,而不支持<body>。這就是生活!

由於我們只〜20行代碼(假設在你的榜樣第二<style>標籤)的交易,你可以嘗試這樣它出現在<head><body>都重複這個<style>標籤。我不確定這是否可行,但值得一試。

+0

這的確是C'est la vie!是的,我已經開始複製了。 (我在代碼中嵌入的