2017-01-11 2 views
1

Я потратил часы, пытаясь создать шаблон электронной почты, который активно работает. Я пытаюсь разместить DIVs рядом друг с другом в BODY электронного письма с подтверждением, которое должно быть отправлено с моего сайта. Таким образом, в результате электронной почты у меня есть это:Как разместить divs рядом друг с другом в почтовом теле?

 <div class="view-content" style="margin-bottom: 20px;"> 
     <h3 style="margin: 0px;font-size: 14px;background-color: #eff1f7;border-top: 1px solid #dedede;border-left: 1px solid #dedede;border-right: 1px solid #dedede;padding: 15px 15px 0 15px;">TESTO 925 - temperaturmätare, typ K, radio, larm,</h3> 
    <div class="views-responsive-grid views-responsive-grid-horizontal views-columns-3 checkout"> 
     <div class="views-row views-row-1 views-row-first" style="background-color: #eff1f7;border-bottom: 1px solid #dedede;border-left: 1px solid #dedede;border-right: 1px solid #dedede;margin: 0px;"> 
     <div class="views-column views-column-1 views-column-first" style="color: #000;"> 

     <div class="views-field views-field-line-item-label" style="float: left;"> <span class="views-label views-label-line-item-label" style="font-weight: bold;font-size: 13px;">Artikelnr: </span> <div class="field-content artikelnr">0560 9250</div> </div> 
     <div class="views-field views-field-commerce-unit-price" style="float: left;"> <span class="views-label views-label-commerce-unit-price" style="font-weight: bold;font-size: 13px;">Pris: </span> <div class="field-content price">995 kr</div> </div> 
     <div class="views-field views-field-quantity" style="float: left;"> <span class="views-label views-label-quantity" style="font-weight: bold;font-size: 13px;">Antal: </span> <div class="field-content antal">1</div> </div> 
     <div class="views-field views-field-commerce-total" style="float: left;"> <span class="views-label views-label-commerce-total" style="font-weight: bold;font-size: 13px;">Summa: </span> <div class="field-content price">995 kr</div> </div> </div> 
     </div> 
     </div> 
     </div> 

Как вы можете видеть, что я пытаюсь использовать float:left здесь, но я также попытался использовать display:table в контейнере (.view-content) и display:table-row и display:table-cell соответственно в других DIVs , Другие вещи, которые я пробовал, это использовать display:block и display:inline-block ... без везения. Так что я делаю неправильно здесь? Почему DIVS с полем класса выше выше отказываются позиционировать себя рядом друг с другом? Есть причины, по которым я не могу использовать простую таблицу, немного длинную для объяснения здесь.

UPD: Хорошо, так что я, наконец, придется отказаться от этого и использовать простую таблицу подход из-за отсутствия поддержки позиционирования ДИВ в популярных почтовых клиентов, как Outlook 2013 ...

+0

скрипка или некоторый код кода CSS могут помочь понять больше :) – semuzaboi

+5

С созданием шаблонов электронной почты HTML вы хотите использовать таблицы, а не div. См. Этот учебник: https://webdesign.tutsplus.com/articles/build-an-html-email-template-from-scratch--webdesign-12770 –

+0

Да, я вижу, что сейчас нет поддержки позиционирования div в Outlook 2010/13 и т. Д. Мне придется пересмотреть мой подход. Большое спасибо в любом случае :-). – TBJ

ответ

1

варианты не следует рассматривать, кроме для тега таблицы при создании Mailers.Even SendGrid предпочитает отправлять почту, которые кодируются с использованием тега table.

Я предпочитаю создавать два DIV с разной или одинаковой шириной, в результате получается в общей сложности 600 пикселей. Затем примените maxwidth, чтобы обе библиотеки DIVs были установлены на мобильных устройствах.

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <title></title> 
    <link rel="stylesheet" href=""> 
</head> 
<body> 
    <table style="max-width:600px;font-family:Arial,Helvetica,sans-serif" align="center" width="100%" border="0" cellpadding="0" cellspacing="0"> 
     <tbody> 
     <tr> 
      <td valign="top"> 
      <table style="text-align:left" align="center" width="100%" border="0" cellpadding="0" cellspacing="0"> 
       <tbody> 
       <tr> 
        <td style="width:100%;border:1px solid #dddddd" valign="top"> 
        <table width="100%" border="0" cellpadding="0" cellspacing="0"> 
         <tbody> 
         <tr> 
          <td valign="top"> 
          <table width="100%" border="0" cellpadding="0" cellspacing="0"> 
           <tbody> 
           <tr> 
            <td style="padding:5px 10px 5px 10px;border-bottom:3px solid #2e3192" valign="top"> 
            <table style="max-width:600px" width="100%" border="0" cellpadding="0" cellspacing="0"> 
             <tbody> 
             <tr> 
              <td> 
              <img src="http://images.sixrevisions.com/2009/02/03-09_3d_logo_tutorial.jpg" style="display:block;max-width:80%;margin-right:15px" align="left" border="0" class="CToWUd" width="150px" height="80px"> 
              </td> 

             </tr> 
             </tbody> 
            </table> 
            </td> 
           </tr> 
           <tr> 
            <td style="font-family:Arial;font-size:15px;padding-top:9px;padding-bottom:9px" width="100%"> 
            <span style="color:#000000;font-weight:bold;font-size:15px;padding-left:9px;font-family:arial">Dear</span> 
            <span style="font-size:14px;font-weight:bold">Amandeep,</span> 

            <br> 
            </td> 
           </tr> 
           <tr> 
            <td><table width="100%" border="0" cellpadding="0" cellspacing="0"> 
            <tbody> 
             <tr> 
             <td style="background:#f1f1f1;padding:7px"> 
              <table style="font-family:Arial;font-size:14px" border="0" bgcolor="#ffffff" width="100%" cellspacing="0" cellpadding="0"> 
              <tbody> 
               <tr> 
               <td style="background:#ffffff;padding:10px"> 
                <table style="font-family:Arial;font-size:14px" border="0" bgcolor="#ffffff" width="100%" cellspacing="0" cellpadding="0"> 
                <tbody> 
                 <tr> 
                 <td> 
                  <h1 style="color:#4e4e4e;font-size:18px;font-weight:bold;display:inline;padding-right:10px">Teddybear Soft Toy </h1> 
                 </td> 
                 </tr> 
                 <tr> 
                 <td colspan="" rowspan="" headers="" style="border-bottom:1px solid #c4c4c4;padding-top:10px"></td> 
                 </tr> 
                </tbody> 
                </table> 
               </td> 
               </tr> 
               <tr> 
               <td align="center"> 
                <div style="display:inline-block;max-width:350px;width:100%;vertical-align:middle"> 
                <table style="padding:5px;font-family:Arial;font-size:13px" border="0" bgcolor="#ffffff" width="100%" cellspacing="0" cellpadding="0"> 
                 <tbody> 
                 <tr> 
                  <td colspan="2">We Want To Buy Teddybear Soft Toy. Kindly share the quotation for the same.</td> 
                 </tr> 
                 </tbody> 
                </table> 
                </div> 
                <div style="display:inline-block;max-width:220px;width:100%;text-align:center;vertical-align:middle"> 
                <table align="center" width="100%" border="0" cellpadding="0" cellspacing="0"> 
                 <tbody> 
                 <tr> 
                  <td align="center"><a style="padding:10px 20px;text-align:center;text-decoration:none;font-weight:bold;border:1px solid #5e9122;background:#5e9122;background:-webkit-gradient(linear,left top,left bottom,from(#5e9122),to(#5e9122));background:-moz-linear-gradient(top,#5e9122,#5e9122);color:#ffffff;border-radius:4px;font-size:17px;width:200px;display:table-cell;margin-left:auto;margin-right:auto" rel="external" href="#">Contact Buyer 
                  </a></td> 
                 </tr> 
                 </tbody> 
                </table> 
                </div> 
               </td> 
               </tr> 
              </tbody> 
              </table> 
             </td> 
             </tr> 
            </tbody> 
            </table> 
           </td></tr> 
           </tbody> 
          </table> 
          </td> 
         </tr> 
         </tbody> 
        </table> 
        </td> 
       </tr> 
       </tbody> 
      </table> 
      </td> 
     </tr> 
     </tbody> 
    </table> 
</body> 
</html> 

Вы можете проверить Mailer с этого сайта PUTSMAIL Работает как шарм на всех почтовых клиентов.

+0

Спасибо за этот пример. Очень полезно! – TBJ

+1

PUTSMAIL - это то, что я тоже тестировал. –

1

Я продолжу и отправлю свой пример. Пример Sudhir Kaushik выглядит хорошо.

<head> 
 
    <style> 
 
    #outlook a{padding:0}body{width:100%!important;background-color:#333;-webkit-text-size-adjust:none;-ms-text-size-adjust:none;margin:0!important;padding:0!important}.ReadMsgBody{width:100%}.ExternalClass{width:100%}ol li{margin-bottom:15px}img{height:auto;line-height:100%;outline:none;text-decoration:none}#backgroundTable{height:100%!important;margin:0;padding:0;width:100%!important}p{margin:1em 0}h1,h2,h3,h4,h5,h6{color:#222!important;font-family:Arial,Helvetica,sans-serif;line-height:100%!important}table td{border-collapse:collapse}.yshortcuts,.yshortcuts a,.yshortcuts a:link,.yshortcuts a:visited,.yshortcuts a:hover,.yshortcuts a span{color:#000;text-decoration:none!important;border-bottom:none!important;background:none!important}.im{color:#000}div[id='tablewrap']{width:100%;max-width:600px!important}table[class='fulltable'],td[class='fulltd']{max-width:100%!important;width:100%!important;height:auto!important}@media screen and (max-device-width: 430px),screen and (max-width: 430px){td[class=emailcolsplit]{width:100%!important;float:left!important;padding-left:0!important;max-width:430px!important}td[class=emailcolsplit] img{margin-bottom:20px!important}} 
 
    </style> 
 
</head> 
 

 
<body style='width:100% !important; margin:0 !important; padding:0 !important; -webkit-text-size-adjust:none; -ms-text-size-adjust:none; background-color:#FFFFFF;'> 
 
    <table border='0' cellpadding='0' align='center' cellspacing='0' id='backgroundTable' style='height:auto !important; margin:0; padding:0; width:100% !important; background-color:#333; color:#222222;'> 
 
    <tr> 
 
     <td> 
 
     <div id='tablewrap' align='center' style='width:100% !important; max-width:600px !important; text-align:center !important; margin-top:0 !important; margin-right: auto !important; margin-bottom:0 !important; margin-left: auto !important;'> 
 
      <table align='center' border='0' cellpadding='0' cellspacing='0' id='contenttable' style='background-color:#FFFFFF; text-align:center !important; margin-top:0 !important; margin-right: auto !important; margin-bottom:0 !important; margin-left: auto !important; border:none; width: 100% !important; max-width:600px !important;' 
 
      width='600'> 
 
      <tr> 
 
       <td width='100%'> 
 
       <table bgcolor='#FFFFFF' border='0' cellspacing='0' style='padding-right:25px' width='100%'> 
 
        <tr> 
 
        <td bgcolor='#FFFFFF' style='text-align:right;' width='100%'> 
 
         <a href='#'><img alt='Main banner image and link' border='0' src='http://placehold.it/72x100' style='display:inline-block; max-width:72px !important; width:100% !important; height:auto !important;'></a> 
 
        </td> 
 
        </tr> 
 
       </table> 
 
       <table bgcolor='#FFFFFF' border='0' cellpadding='25' cellspacing='0' width='100%'> 
 
        <tr> 
 
        <td bgcolor='#FFFFFF' style='text-align:left;' width='100%'> 
 
         <p style='color:#222222; font-family:Arial, Helvetica, sans-serif; font-size:15px; line-height:19px; margin-top:0; margin-bottom:20px; padding:0; font-weight:normal;'> 
 
         Dear Customer, 
 
         </p> 
 
         <p style='color:#222222; font-family:Arial, Helvetica, sans-serif; font-size:15px; line-height:19px; margin-top:0; margin-bottom:20px;margin-left:20px; padding:0; font-weight:normal;'> 
 
         Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor 
 
         in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 
 
         </p> 
 
         <table border='0' cellpadding='0' cellspacing='0' class='emailwrapto100pc' width='100%'> 
 
         <tr> 
 
          <td align='right' class='emailcolsplit' valign='top' width='100%'> 
 
          <p style='color:#222222; font-family:Arial, Helvetica, sans-serif; font-size:15px; line-height:19px; margin-top:0; margin-bottom:20px; margin-left:20px; padding:0; font-weight:normal; text-align:left;'> 
 
           Please call us at 555-555-5555 with any questions. 
 
          </p> 
 
          </td> 
 
         </tr> 
 
         <tr> 
 
          <td align='left' class='emailcolsplit' valign='top' width='58%'> 
 
          <address style='font-size:15px; margin: 0; line-height: 1.25em; font-family: Helvetica, Arial'> 
 
      <p> 
 
      <span style='font-weight:600; font-size: 18px'>Your Company Inc</span><br> 
 
      400 Tech Drive<br> 
 
      Some City, State 22222<br> 
 
      <abbr title='Phone'><strong>P:</strong></abbr>555.555.5555<br> 
 
      <strong>Email:</strong><a href='mailto:[email protected]'>[email protected]</a> 
 
      </p> 
 
      </address> 
 
          </td> 
 
         </tr> 
 
         </table> 
 
        </td> 
 
        </tr> 
 
       </table> 
 
       </td> 
 
      </tr> 
 
      </table> 
 
     </div> 
 
     </td> 
 
    </tr> 
 
    </table> 
 
</body>

Так красиво право? Это форматирование сводит меня с ума. Моя электронная почта была ответом на клиентов, но я уверен, что ее можно легко применить к другим сценариям.
Удачи!

+0

Хороший, у меня был некоторый стенографический CSS, но отлично работает, за исключением тени для ящиков и радиуса границы в Outlook и старых версиях yahoo. –

+0

Отличная работа! В этих примерах я уверен, что создаю что-то полезное для клиента. Еще раз спасибо! – TBJ

Смежные вопросы