2016-07-09 3 views
1

Hallo liebe Webentwickler!Responsive HTML E-Mails

Ich habe ein Problem mit der E-Mail-Anzeige in Outlook-Clients auf Mobiltelefonen und sogar auf Outlook auf meinem Desktop-PC.

Wenn ich meine E-Mail in Outlook erhalte und sie im Internet Explorer öffne, versuche ich die Größe zu ändern und wenn es zu dem Punkt kommt, an dem es zum @media-Bildschirm wechseln muss, bricht alles zusammen. Es passiert in fast jedem Outlook-Client auf Mobiltelefonen.

Hier ist die Sache. Wenn ich F12 auf der E-Mail drücke, die in IE geöffnet wird, sehe ich, dass mein Inline-Stil für die Breite durchgestrichen ist und die .col-Klasse in Kraft ist. Aber es zeigt immer noch nicht die E-Mail richtig und ansprechend. Dies geschieht nur in Outlook. Irgendeine Idee, wie man es repariert? Hier

ist der Teil des Codes:

<style> 
    @media screen and (max-width: 525px) { 
     /* FLUID TABLES */ 
     .wrapper { 
      width: 100% !important; 
      max-width: 100% !important; 
     } 
     /*COLUMNS TO ROWS */ 
     .col { 
      display: block!important; 
      width: 100%!important; 
      border: none!important; 
     } 

     .img-max { 
      max-width: 100% !important; 
      width: 100% !important; 
      height: auto !important; 
     } 
     .wide { 
      width: 100% !important; 
     } 
     } 
</style> 

<table style="padding-top: 0px;padding-right: 15px;padding-bottom: 0px;padding-left: 15px;table-layout: auto;" border="0" cellpadding="0" cellspacing="0" width="100%"> 
    <tbody> 
     <tr> 
      <td style="padding-top: 0px;padding-right: 15px;padding-bottom: 20px;padding-left: 15px; background-color: rgb(255, 255, 255);" class="section-pad" align="center"> 
       <!--[if (gte mso 9)|(IE)]> 
      <table align="center" border="0" cellspacing="0" cellpadding="0" width="700"> 
      <tr> 
      <td align="center" valign="top" width="700"> 
      <![endif]--> 
       <table style="max-width: 700px;table-layout: auto;" class="wide" border="0" cellpadding="0" cellspacing="0" width="100%"> 
        <tbody> 
         <tr> 
          <td style="background-color: rgb(236, 242, 248);"> 
           <!-- HERO IMAGE --> 
           <table style="table-layout: auto; background-color: rgb(236, 242, 248); width: 92%;" border="0" cellpadding="0" cellspacing="0" width="100%" align="center"> 
            <tbody> 
             <tr> 
              <td class="col" align="center" valign="top" style="width: 65%; padding-left: 0px; background-color: rgb(236, 242, 248);"> 
               <table style="table-layout: auto; background-color: white; padding-left: 10px; padding-right: 10px;" border="0" cellpadding="0" cellspacing="0" width="100%"> 
                <tbody> 
                 <tr> 
                  <td style="padding-top: 15px;padding-right: 20px;padding-bottom: 0;padding-left: 20px;font-size: 26px;line-height: 30px;font-weight:400; font-family: Arial, sans-serif; color: #0056a6;" align="left"><img src="/resources/handlers/dcimage.ashx" style="height: auto; display: inline;" border="0">,</td> 
                 </tr> 
                 <tr> 
                  <td style="padding-top: 15px;padding-right: 20px;padding-bottom: 20px;padding-left: 20px; font-size: 14px; font-weight:normal; line-height: 14px; font-family: Arial, sans-serif; color: #2d353d;" align="left"> 
                   LOREM IPSUM 
                  </td> 
                 </tr> 
                </tbody> 
               </table> 
              </td> 
              <td style="background-color: rgb(236, 242, 248); width: 35%; padding-right: 0px;" class="col" align="center" valign="top"> 
               <p valign="middle" style="line-height: 40px; font-size: 12px; color: white; font-family: Arial, sans-serif; background-color: rgb(0, 86, 166);"> 
                In case you need to contact us</p> 
               <img src="/r1.jpg" alt="telephone" class="img-max" border="0" height="50" width="240"> 
               <img src="/r2.jpg" alt="skype" class="img-max" border="0" height="50" width="240"> 
               <img src="/r3.jpg" alt="mail" class="img-max" border="0" height="50" width="240"> 
               <img src="/r4.jpg" alt="web" class="img-max" border="0" height="50" width="240"> 

              </td> 
             </tr> 
             <tr> 
              <td class="col" align="center" valign="top" style="width: 65%;"> 
              <img src="/r2.jpg" class="img-max"> 
              </td> 
              <td style="background-color: rgb(236, 242, 248); width: 35%;" class="col" align="center" valign="top">&nbsp;</td> 
             </tr> 
            </tbody> 
           </table> 
          </td> 
         </tr> 
        </tbody> 
       </table> 
       <!--[if (gte mso 9)|(IE)]> 
      </td> 
      </tr> 
      </table> 
      <![endif]--> 
      </td> 
     </tr> 
    </tbody> 
</table> 
+0

Nur zu beachten, dass, wenn ich die Col-Klasse von meinem TD entfernen, alles gut ist, aber reaktionsschnelle Teil ist nicht gut: D Sollte ich Outlook so verhalten, wie es will? – bocasa

Antwort

0

Wie ich mich erinnere, Outlook mobile Anwendungen nicht reagiert, E-Mails unterstützen. Ich glaube nicht das display: block; funktioniert auf ihnen (wie bei den meisten Android-E-Mail-Clients). Die Responsive-Methode, die Sie verwenden nur funktioniert zuverlässig auf nativen iPhone-Apps.

1

Wenn ich richtig verstehe, ist das Verhalten, das Sie wollen, jeden Ihrer Spalten Markt mit class = "col" in eine Zeile fallen, wenn Ihre Medienabfrage für kleine Bildschirme in Kraft tritt.

Zunächst wird Outlook alle In-Line-Stile (wie Sie mit F12 bemerkt haben) entfernen, also am besten verdoppeln, indem Sie die entsprechenden HTML-Attribute für jedes Ihrer Elemente verwenden. Zweitens wird max-width von Outlook (und Lotus Notes 8 & 8.5) nicht unterstützt, Sie müssen also alle Ihre <table> s, die sich in Ihren col-Spalten befinden, in bedingten Code umwandeln, der eine Tabelle mit erstellt eine festgelegte Breite, in der alles enthalten ist, die auf IE und Microsoft Outlook ausgerichtet ist. Sie werden so etwas wie verwenden müssen:

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

    <table style="table-layout: auto; background-color: white; padding-left: 10px; padding-right: 10px;" border="0" cellpadding="0" cellspacing="0" width="100%"> 
     <tbody> 
      <tr> 
       <td style="padding-top: 15px;padding-right: 20px;padding-bottom: 0;padding-left: 20px;font-size: 26px;line-height: 30px;font-weight:400; font-family: Arial, sans-serif; color: #0056a6;" align="left"><img src="/resources/handlers/dcimage.ashx" style="height: auto; display: inline;" border="0">,</td> 
      </tr> 
      <tr> 
       <td style="padding-top: 15px;padding-right: 20px;padding-bottom: 20px;padding-left: 20px; font-size: 14px; font-weight:normal; line-height: 14px; font-family: Arial, sans-serif; color: #2d353d;" align="left"> 
                  LOREM IPSUM 
       </td> 
      </tr> 
     </tbody> 
    </table> 

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

würde ich nach dieser guide to build responsive emails that work on all major mail clients für eine tiefer gehende Erklärung dafür stark empfehlen, und auch andere sehr nützliche Tricks für die Herstellung von E-Mail-Arbeit auch auf Outlook :)

1

Hmm, ich bin mir nicht sicher, ob die mobilen Outlook-Apps Medienabfragen unterstützen. Die mobilen Apps sind viel besser beim Rendern von Markup als ihre Desktop-Gegenstücke (jedenfalls unter Windows).

Egal, Hybrid-Design erreicht ein reaktionsschnelles, Shape-Shift-Layout ohne Medienabfragen zu verlassen. Ihr Code oben ist in die richtige Richtung, obwohl das Beispiel unten ein wenig anders ist. Hier ist ein einfaches 2-Säulen-Gerüst von Fabio Carneiro's code samples on GitHub (alle Krediten ihm!):

<!doctype html> 
 
<html> 
 
\t <body style="margin:0;"> 
 
\t \t <center> 
 
\t \t \t <table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%"> 
 

 

 

 

 
\t \t \t \t <!-- // 2-COLUMN SCAFFOLD [CENTERING, FLUID] --> 
 
\t \t \t \t <tr> 
 
\t \t \t \t \t <td align="center" height="100%" valign="top" width="100%"> 
 
\t \t \t \t \t \t <!--[if mso]> 
 
\t \t \t \t \t \t <table align="center" border="0" cellspacing="0" cellpadding="0" width="660"> 
 
\t \t \t \t \t \t <tr> 
 
\t \t \t \t \t \t <td align="center" valign="top" width="660"> 
 
\t \t \t \t \t \t <![endif]--> 
 
\t \t \t \t \t \t <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width:660px;"> 
 
\t \t \t \t \t \t \t <tr> 
 
\t \t \t \t \t \t \t \t <td align="center" valign="top" style="font-size:0;"> 
 
\t \t \t \t \t \t \t \t \t <!--// DEVELOPER NOTES: 
 
\t \t \t \t \t \t \t \t \t \t 1. Setting font-size:0; is necessary to ensure 
 
\t \t \t \t \t \t \t \t \t \t that there is no extra spacing introduced 
 
\t \t \t \t \t \t \t \t \t \t between the centering divs that wrap each 
 
\t \t \t \t \t \t \t \t \t \t of the columns. //--> 
 

 
\t \t \t \t \t \t \t \t \t <!--[if mso]> 
 
\t \t \t \t \t \t \t \t \t <table align="center" border="0" cellspacing="0" cellpadding="0" width="660"> 
 
\t \t \t \t \t \t \t \t \t <tr> 
 
\t \t \t \t \t \t \t \t \t <td align="left" valign="top" width="330"> 
 
\t \t \t \t \t \t \t \t \t <![endif]--> 
 
\t \t \t \t \t \t \t \t \t <div style="display:inline-block; max-width:50%; min-width:240px; vertical-align:top; width:100%;"> 
 
\t \t \t \t \t \t \t \t \t \t <!--// DEVELOPER NOTES: 
 
\t \t \t \t \t \t \t \t \t \t \t 1. To have each column center upon stacking, 
 
\t \t \t \t \t \t \t \t \t \t \t wrap them in individual divs, set the same 
 
\t \t \t \t \t \t \t \t \t \t \t max-width and width as the table within it, 
 
\t \t \t \t \t \t \t \t \t \t \t and set display to inline-block; using 
 
\t \t \t \t \t \t \t \t \t \t \t vertical-align is optional. 
 

 
\t \t \t \t \t \t \t \t \t \t \t 2. Setting min-width determines when the two 
 
\t \t \t \t \t \t \t \t \t \t \t columns of this block will wrap; in this 
 
\t \t \t \t \t \t \t \t \t \t \t case, when the total available width is 
 
\t \t \t \t \t \t \t \t \t \t \t less than or equal to 480px. //--> 
 

 
\t \t \t \t \t \t \t \t \t \t <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width:330px;"> 
 
\t \t \t \t \t \t \t \t \t \t \t <tr> 
 
\t \t \t \t \t \t \t \t \t \t \t \t <td align="center" valign="top"> 
 
\t 
 
\t \t \t \t \t \t \t \t \t \t \t \t \t <!-- // REPLACE WITH BLOCK --> 
 
\t \t \t \t \t \t \t \t \t \t \t \t \t <p style="background-color:#2BAADF; color:#FFFFFF; font:16px Helvetica, sans-serif, normal; margin:0 !important; padding:10px;">LEFT</p> 
 
\t \t \t \t \t \t \t \t \t \t \t \t \t <!-- REPLACE WITH BLOCK // --> 
 
\t 
 
\t \t \t \t \t \t \t \t \t \t \t \t </td> 
 
\t \t \t \t \t \t \t \t \t \t \t </tr> 
 
\t \t \t \t \t \t \t \t \t \t </table> 
 
\t \t \t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t \t \t \t <!--[if mso]> 
 
\t \t \t \t \t \t \t \t \t </td> 
 
\t \t \t \t \t \t \t \t \t <td align="left" valign="top" width="330"> 
 
\t \t \t \t \t \t \t \t \t <![endif]--> 
 
\t \t \t \t \t \t \t \t \t <div style="display:inline-block; max-width:50%; min-width:240px; vertical-align:top; width:100%;"> 
 
\t \t \t \t \t \t \t \t \t \t <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width:330px;"> 
 
\t \t \t \t \t \t \t \t \t \t \t <tr> 
 
\t \t \t \t \t \t \t \t \t \t \t \t <td align="center" valign="top"> 
 
\t 
 
\t \t \t \t \t \t \t \t \t \t \t \t \t <!-- // REPLACE WITH BLOCK --> 
 
\t \t \t \t \t \t \t \t \t \t \t \t \t <p style="background-color:#51BBE5; color:#FFFFFF; font:16px Helvetica, sans-serif, normal; margin:0 !important; padding:10px;">RIGHT</p> 
 
\t \t \t \t \t \t \t \t \t \t \t \t \t <!-- REPLACE WITH BLOCK // --> \t 
 
\t 
 
\t \t \t \t \t \t \t \t \t \t \t \t </td> 
 
\t \t \t \t \t \t \t \t \t \t \t </tr> 
 
\t \t \t \t \t \t \t \t \t \t </table> 
 
\t \t \t \t \t \t \t \t \t </div> 
 
\t \t \t \t \t \t \t \t \t <!--[if mso]> 
 
\t \t \t \t \t \t \t \t \t </td> 
 
\t \t \t \t \t \t \t \t \t </tr> 
 
\t \t \t \t \t \t \t \t \t </table> 
 
\t \t \t \t \t \t \t \t \t <![endif]--> 
 
\t \t \t \t \t \t \t \t </td> 
 
\t \t \t \t \t \t \t </tr> 
 
\t \t \t \t \t \t </table> 
 
\t \t \t \t \t \t <!--[if mso]> 
 
\t \t \t \t \t \t </td> 
 
\t \t \t \t \t \t </tr> 
 
\t \t \t \t \t \t </table> 
 
\t \t \t \t \t \t <![endif]--> 
 
\t \t \t \t \t </td> 
 
\t \t \t \t </tr> 
 
\t \t \t \t <!-- 2-COLUMN SCAFFOLD [CENTERING, FLUID] // --> 
 

 

 

 

 
\t \t \t </table> 
 
\t \t </center> 
 
\t </body> 
 
</html>

Es gibt mehr Gerüste und Muster in diesem Repo- und anderswo, aber dies zeigt das Grundprinzip in Aktion.

(Wenn Sie noch nicht wissen, wie das funktioniert) verwendet diese Methode maximale Breite und minimale Breite, um starre Basislinien zu erzwingen (erlaubt etwas Bewegung) und legt eine feste, breite Breite für Outlook fest, die ohnehin an den Desktop gefesselt ist .Sobald eine für Mobilgeräte optimierte Baseline festgelegt ist, werden die E-Mails in Medienabfragen schrittweise in Clients erweitert, die sie unterstützen (z. B. iOS Mail).