首页 > 解决方案 > 重新排序电子邮件的表格元素

问题描述

我一直在玩,无法弄清楚,所以一些建议将不胜感激!

https://codepen.io/chaser87/pen/ZEQvydw

我想知道的仅涉及以 Meet your Department 为首的部分。当你缩小这封电子邮件时,它几乎是我想要的。但是,我想重新排序该部分中的图像和副本块。基本上,我首先要图片,然后是副本。我试过用元素做 nth-of-type 的东西,但没有用。

对于额外的背景,每个部分都是一个 100% 的表格,其中有一个 600 像素的表格,然后是另一个 100% 的表格。

 <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <link rel="stylesheet" type="text/css" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
        <link href="https://fonts.googleapis.com/css2?family=Fjalla+One&display=swap" rel="stylesheet">
        <title>Boundless opportunities</title>
        <style type="text/css">/*<![CDATA[*//* CLIENT-SPECIFIC STYLES */
            body, table, td, hr, a { -webkit-text-size-adjust: 100%; -ms-textsize-adjust: 100%; }
            table, td { mso-table-lspace: 0pt; mso-table-rspace: 0pt; }
            img { -ms-interpolation-mode: bicubic; }
    
    /* RESET STYLES */
            img { border: 0; height: auto; line-height: 100%; outline: none;
            text-decoration: none; }
            table { border-collapse: collapse !important; }
            body { height: 100% !important; margin: 0 !important; padding: 0
            !important; width: 100% !important; }
    
            
            @media screen and (max-width: 616px) {
                
                .fluid-table {
                        width: 100% !important;
                }
                table {
                        width: 100% !important;                 
                }
                td {
                    display: block !important;          
                }
                td img {
                        display: block !important;
                        width: 60% !important;
                        margin-left: auto !important;
                        margin-right: auto !important; 
                        padding: 0px 0px 0px 0px !important;
                }
                
                h3 {
                    margin-top: 0 !important;
                    margin-bottom: 0 !important;
                }
                
                .paragraph-copy {
                    padding: 20px 15px 20px 15px !important;
                    font-size: 100% !important;
                    line-height: 25px !important;
                }
                .paragraph-align {
                    text-align: center !important;
                }
                    
                .social-icons {
                        padding: 5px 5px 10px 5px !important;
                        display: inline !important;
                        width: 15% !important;                  
                }
                    
            }/*]]>*/
            
            
            
        </style>
      </head>
      <body style="margin: 0 !important; padding: 0 !important;">
        <!--END OF PREVIEW TEXT-->
         
        <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="background-color: #FFFFFF;" width="100%">
          <tbody>
            <tr>
              <td align="center">
              <table border="0" cellpadding="0" cellspacing="0" class="fluid-table" role="presentation" width="600px">
                <tbody>
                  <tr>
                    <td>
                    <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                      <tbody>
                        <tr>
                          <td><img alt="It's your time. Apply in July! Join the Cowboy family as part of #okstate25 and you'll get a free T-shirt!" class="fluid-table" src="https://dummyimage.com/1200x696/000/fff" style="width: 600px;"/>
                        </td>
                        </tr>
                        <tr>
                          <td class="paragraph-copy" style="padding: 5px 10px 10px 10px; font-family: Gotham, 'Helvetica Neue', Helvetica, Arial, 'sans-serif'; font-size: 15px; line-height: 22px; text-align: left;">
                            <p>{{First}},</p>
                            <p>We're excited to welcome you to the {{collegename}}! We look forward to seeing what the future holds for you as a {{major}} major within the Department of {{department}}.</p>
                          <p>We are here to assist you and look forward to working with you during your time at Generic State University. If we can help you in any way, please let us know. Again, congratulations on taking the next step and joining the {{college}}!&nbsp;</p></td>
                        </tr>
                        <!--FIRST ROW WITH PIC-->
                      </tbody>
                    </table>
    
                    <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="background-color: #E3E3E3" width="100%">
                      <tbody>
                        <tr>
                          <td align="center">
                          <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="600"><!--TWO COLUMN SECTION-->
                            <tbody>
                              <tr>
                                <td align="center"><!--TWO COLUMNS-->
                                <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                  <tbody>
                                    <tr>
                                      <td style="padding: 0px 10px 0px 10px"><!--LEFT COLUMN-->
                                      <table align="left" border="0" cellpadding="0" cellspacing="0" role="presentation" width="36%">
                                        <tbody>
                                          <tr>
                                            <td>
                                            <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                              <tbody>
                                                <tr style="display: block; align-items: center; justify-content: space-between">
                                                  <td align="center" style="padding-top: 15px">
                                                    <!--CONTENT-->
                                                      <img src="https://dummyimage.com/220x220/000/fff" style="width: 220px;">
                                                    </td>
                                                </tr>
                                              </tbody>
                                            </table>
                                            </td>
                                          </tr>
                                        </tbody>
                                      </table>
                                      <!--RIGHT COLUMN-->
    
                                      <table align="right" border="0" cellpadding="0" cellspacing="0" role="presentation" width="56%">
                                        <tbody>
                                          <tr>
                                            <td>
                                            <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                              <tbody>
                                                <tr style="display: block; align-items: center; justify-content: space-between">
                                                  
                                                    
                                                    
                                                    <td class="paragraph-align paragraph-copy" align="left" style="font-family: Gotham, 'Helvetica Neue', Helvetica, Arial, 'sans-serif'; font-size: 15px; line-height: 22px; padding: 5px 10px 20px 10px"><!--CONTENT-->
                                                  <h3>
                                                    <span>Meet Your Academic Advisor</span>
                                                  </h3>
    
                                                  <p>{{Advisor_Name}}</p>
                                                  <p>{{Advisor_Address}}</p>
                                                  <p>{{Advisor_Phone_Number}}&nbsp; </p>
                                                  <p>{{Advisor_Email}}</p>
                                                  <p>{{Advisor_Bio Page}}</p></td>
                                                </tr>
                                              </tbody>
                                            </table>
                                            </td>
                                          </tr>
                                        </tbody>
                                      </table>
                                      </td>
                                    </tr>
                                  </tbody>
                                </table>
                                </td>
                              </tr>
                              <!--END OF 2 COLUMN SECTION-->
                            </tbody>
                          </table>
                          </td>
                        </tr>
                      </tbody>
                    </table>
                    <!--SECOND ROW WITH PIC-->
    
                    <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                      <tbody>
                        <tr>
                          <td align="center">
                          <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="600"><!--TWO COLUMN SECTION-->
                            <tbody>
                              <tr>
                                <td align="center" style="vertical-align: top;"><!--TWO COLUMNS-->
                                <table align="" border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                  <tbody>
                                    <tr>
                                      <td style="padding: 10px 10px 10px 10px"><!--LEFT COLUMN-->
                                      <table align="left" border="0" cellpadding="0" cellspacing="0" role="presentation" width="58%">
                                        <tbody>
                                          <tr>
                                            <td>
                                            <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                              <tbody>
                                                <tr style="display: block; align-items: center; justify-content: space-between">
                                                  <td class="paragraph-copy paragraph-align" align="left" style="font-family: Gotham, 'Helvetica Neue', Helvetica, Arial, 'sans-serif'; font-size: 15px; line-height: 22px; padding: 10px 10px 10px 10px"><!--CONTENT-->
                                                  <h3>
                                                    <span>Meet Your Department</span>
                                                  </h3>
                                                      <p>The {{Department}} is looking forward to your addition to the {{College}} family!&nbsp;</p>
                                                      <p>The main office for your department is located in {{department_address}} and you can reach them by phone at {{department_number}} or by emailing {{department_email}}.</p></td>
                                                </tr>
                                              </tbody>
                                            </table>
                                            </td>
                                          </tr>
                                        </tbody>
                                      </table>
                                      <!--RIGHT COLUMN-->
    
                                      <table align="right" border="0" cellpadding="0" cellspacing="0" role="presentation" width="36%">
                                        <tbody>
                                          <tr>
                                            <td>
                                            <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                              <tbody>
                                                <tr style="display: block; align-items: center; justify-content: space-between">
                                                  <!--CONTENT-->
                                                  <td align="center" style="padding: 15px 10px 10px 10px;"><img src="https://dummyimage.com/200x200/000/fff" style="width: 200px"></td>
                                                </tr>
                                              </tbody>
                                            </table>
                                            </td>
                                          </tr>
                                        </tbody>
                                      </table>
                                      </td>
                                    </tr>
                                  </tbody>
                                </table>
                                </td>
                              </tr>
                              <!--END OF 2 COLUMN SECTION-->
                            </tbody>
                          </table>
                          </td>
                        </tr>
                      </tbody>
                    </table>
                        
                        
                    <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="background-color: #E3E3E3" width="100%">
                      <tbody>
                        <tr>
                          <td align="center">
                          <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="600"><!--TWO COLUMN SECTION-->
                            <tbody>
                              <tr>
                                <td align="center"><!--TWO COLUMNS-->
                                <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                  <tbody>
                                    <tr>
                                      <td style="padding: 5px 10px 0px 10px"><!--LEFT COLUMN-->
                                      <table align="left" border="0" cellpadding="0" cellspacing="0" role="presentation" width="36%">
                                        <tbody>
                                          <tr>
                                            <td>
                                            <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                              <tbody>
                                                <tr style="display: block; align-items: center; justify-content: space-between">
                                                  <td align="center" style="padding: 20px 10px 0px 10px">
                                                    <!--CONTENT-->
                                                      <img src="https://dummyimage.com/210x210/000/fff" style="width: 210px">
                                                    </td>
                                                </tr>
                                              </tbody>
                                            </table>
                                            </td>
                                          </tr>
                                        </tbody>
                                      </table>
                                      <!--RIGHT COLUMN-->
    
                                      <table align="right" border="0" cellpadding="0" cellspacing="0" role="presentation" width="56%">
                                        <tbody>
                                          <tr>
                                            <td>
                                            <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                              <tbody>
                                                <tr style="display: block; align-items: center; justify-content: space-between">
                                                  
                                                    
                                                    
                                                    <td class="paragraph-copy" align="left" style="font-family: Gotham, 'Helvetica Neue', Helvetica, Arial, 'sans-serif'; font-size: 15px; line-height: 22px; padding: 5px 10px 0px 10px"><!--CONTENT-->
                                                  <h3>
                                                    <span>Mark Your Calendar</span>
                                                  </h3>
    
                                                  <p>Aug. 14 | Sample Event</p>
                                                  <p>Aug. 14 | Sample Event</p>
                                                  <p>Aug. 14 | Sample Event</p>
                                                  <p>Aug. 14 | Sample Event</p>
                                                  <p>Aug. 14 | Sample Event</p>
                                                  </td>
                                                </tr>
                                              </tbody>
                                            </table>
                                            </td>
                                          </tr>
                                        </tbody>
                                      </table>
                                      </td>
                                    </tr>
                                  </tbody>
                                </table>
                                </td>
                              </tr>
                              <!--END OF 2 COLUMN SECTION-->
                            </tbody>
                          </table>
                          </td>
                        </tr>
                      </tbody>
                    </table>
                        
                    
    
                    <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="background-color: #E3E3E3" width="100%">
                      <tbody>
                        <tr>
                          <td align="center">
                          <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="600"><!--CONTENT-->
                            <tbody>
                              <tr>
                                <td align="center">
                                <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                  <tbody>
                                    <tr>
                                      <td align="center" style="font-family: Gotham, 'Helvetica Neue', Helvetica, Arial, 'sans-serif'; font-size: 15px; line-height: 22px; padding: 15px 0px 5px 0px; vertical-align: top;"><hr style="border-top: 2px solid #000000; width: 50%;">
                                        <p style="padding-top: 15px;">Bookmark these calendars to stay informed about what's going on:</p>
                                        <p><a style="color: #FE5C00" href="#"><strong>Academic College Calendar</strong></a><strong> | <a style="color: #FE5C00" href="#">College Calendar</a> | <a style="color: #FE5C00" href="#">Athletics Calendar</a></strong></p></td>
                                    </tr>
                                  </tbody>
                                </table>
                                </td>
                              </tr>
                            </tbody>
                          </table>
                          </td>
                        </tr>
                      </tbody>
                    </table>
                    <!--BOTTOM ROW LINK STORIES-->
    
                   <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="background-color: #FFFFFF;" width="100%">
          <tbody>
            <tr>
              <td align="center">
              <table border="0" cellpadding="0" cellspacing="0" class="fluid-table" role="presentation" width="600px">
                <tbody>
                  <tr>
                    <td>
                    <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                      <tbody>
                        <tr>
                          <td><img alt="It's your time. Apply in July! Join the Cowboy family as part of #okstate25 and you'll get a free T-shirt!" class="fluid-table" src="https://dummyimage.com/600x95/0fe5c1/fff" style="width: 600px; display: block;" /></td>
                        </tr>
                        <!--FIRST ROW WITH PIC-->
                      </tbody>
                    </table> 
                        
                        
                        <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%" style="background-color: black">
                      <tbody>
                        <tr>
                          <td align="center">
                          <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="600"><!--TWO COLUMN SECTION-->
                            <tbody>
                              <tr>
                                <td align="center"><!--TWO COLUMNS-->
                                <table align="" border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                  <tbody>
                                    <tr>
                                      <td><!--LEFT COLUMN-->
                                      <table align="left" border="0" cellpadding="0" cellspacing="0" role="presentation" width="56%">
                                        <tbody>
                                          <tr>
                                            <td valign>
                                            <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                              <tbody>
                                                <tr style="display: block; align-items: center; justify-content: space-between">
                                                  <td align="left" style="padding: 10px 0px 10px 10px; font-family: Gotham, 'Helvetica Neue', Helvetica, Arial, 'sans-serif'; font-size: 12px; line-height: 18px; color: #FFFFFF"><!--CONTENT-->
                                                  
                                                      <p>College of Engineering&nbsp;<br>
                                                        Generic State University<br>
                                                        136 Whatever Building | Orlando, FL 00000</p>
                                                      </td>
                                                </tr>
                                              </tbody>
                                            </table>
                                            </td>
                                          </tr>
                                        </tbody>
                                      </table>
                                      <!--RIGHT COLUMN-->
    
                                      <table align="right" border="0" cellpadding="0" cellspacing="0" role="presentation" width="38%">
                                        <tbody>
                                          <tr>
                                            <td>
                                            <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                              <tbody>
                                                <tr style="display: block; align-items: center; justify-content: space-between"><!--CONTENT-->
                                                  
                                      <td align="right" style="padding: 25px 15px 20px 0px;"><img alt="OSU's Facebook Page" class="social-icons" src="https://dummyimage.com/45x45/ddad45/fff" style="width: 45px;" />&nbsp; <img alt="OSU's Twitter Page" class="social-icons" src="https://dummyimage.com/45x45/ddad45/fff" style="width: 45px;" />&nbsp; <img alt="OSU's Instagram Page" class="social-icons" src="https://dummyimage.com/45x45/ddad45/fff" style="width: 45px;" />&nbsp; <img alt="OSU's Snapchat Page" class="social-icons" src="https://dummyimage.com/45x45/ddad45/fff" style="width: 45px;" /></td>
                                                
                                              </tbody>
                                            </table>
                                            </td>
                                          </tr>
                                        </tbody>
                                      </table>
                                      </td>
                                    </tr>
                                  </tbody>
                                </table>
                                </td>
                              </tr>
                              <!--END OF 2 COLUMN SECTION-->
                            </tbody>
                          </table>
                          </td>
                        </tr>
                      </tbody>
                    </table>
    
                   
                                    
                        
                        
                        
                        
                        
                    </td>
                  </tr>
                </tbody>
              </table>
              </td>
    
    
            </tr>
          </tbody>
        </table>
                  
      </body>
    </html>

标签: htmlcssemail

解决方案


reverse类添加到包含 Meet Your Department 部分的两列的单元格中,并在您的媒体查询中使用以下 CSS:

td:not(.reverse) {
    display: block !important;
}

td.reverse {
    display: flex;
    flex-direction: column-reverse;
}

推荐阅读