Определенный способ сложить строки таблицы в адаптивном дизайне - с медиа-запросами или без них? - PullRequest
0 голосов
/ 29 ноября 2018

Я прочитал множество статей, в которых подробно описывается, как создавать стекируемые строки таблицы для адаптивных электронных писем, но я не могу заставить его работать.Я работаю над электронной почтой, и вот код.Класс class = social - это вопрос.В оригинальном коде, который я копирую, они использовали div.кажется, что они написаны для Интернета, а не для электронной почты.

Насколько я понимаю, таблицы без медиазапросов - лучший способ создания отзывчивых электронных писем в формате HTML.Как бы я сделал это в электронном письме, которое я проектирую здесь?Полный код ниже.Таблица, о которой идет речь, является таблицей class = "social"

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Really Good Emails</title>
    <style type="text/css">
        body {
          background-color:#f7f7f7;
          color:#5f5f5f;
          font-family: Roboto,Tahoma,sans-serif;
              }
        h1 {
          color:#404040;
        }

        .button {
          opacity:1;
          transition:0.3s;
            }

        .button:hover {opacity:0.6}

        .header {
          background-image: url("http://i1.createsend1.com/ei/i/53/DC3/DE5/174640/csfinal/email-background2.jpg");
          border-spacing: 0px;
          border-collapse: collapse;
          padding-bottom:0px;
        }

        a {
          text-decoration:none;
          display: block;

          }
        .btn {
          opacity:1;
        }

        .btn:hover {
          opacity:.8;
        }

@media only screen and (max-width:510px)  {

    body {max-width: 100% !important;padding:0 !important;margin:0 !important;}
    .header {max-width: 100% !important; padding:0 !important;margin:0 !important;}
    .header img {width:300px !important;height:auto !important;}
    .friday {max-width:100% !important;display:flex;align-items: center;padding-bottom:0px;}
    .friday img {max-width:100% !important;height:auto !important;}
    .advertise img {display:block !important; width:100% !important; height:auto !important; max-width:100% !important;height:auto !important;}
    .advertise {display:block !important; width:100% !important; height:auto !important; max-width:100% !important;
      height:auto !important;border-collapse: collapse !important; table-layout: fixed !important;border-spacing:0;}
    .friday h1 {padding: 0 0 0 15px !important;}
    .curved {display:none !important;}
     p {font-size:1rem !important;}
     td {max-width: 100% !important;}
    .footer p {font-size:.7rem !important;}
    .cliff {max-width:100% !important; padding-bottom:0px !important;}
    .social {max-width:100% !important; display:flex;align-items: center;flex-direction:column;}
    .social a {width:95%;}
    .space {display:none !important;}
    }



    </style>
  </head>
  <body>
<table class="header" width="100%" bgcolor="#fe4c44" cellspacing="0" cellpadding="0">
  <tr>
    <td style="padding: 25px 0 25px 0; display:block;" align="center">
      <a href="https://reallygoodemails.com/?utm_campaign=complete-your-profile&utm_source=ReallyGoodEmails&utm_medium=email">
      <img style="display:block;" width="600px" height="64px" alt="Really Good Emails" src="http://i1.createsend1.com/ei/i/53/DC3/DE5/174640/csfinal/header_RGE-logo-9900000000079e3c.png">
      </a>
    </td>
  </tr>
  <tr>
    <td align="center">
      <img class="curved" style="display:block; max-width:600px;" width="600px" height="32px" src="http://i2.createsend1.com/ei/i/53/DC3/DE5/174640/csfinal/top-rounded3-9900000000079e3c.png">
    </td>
  </tr>
</table>

<table class="friday" style="padding-bottom:0px;" align="center" width="600px" bgcolor="white">
  <tr>
    <td align="center" color="#5f5f5f;">
      <a href="https://www.youtube.com/watch?v=-txf0GL1wK4&feature=youtu.be"><img width="560px" height="398px" alt="Feedback Friday"
      src="http://i3.createsend1.com/ei/i/53/DC3/DE5/174640/csfinal/feedback-compressed-9900000000079e3c.png"></a>
      <h1 style="font-family: Roboto,Tahoma,sans-serif; font-size:1.5rem; line-height:30px;padding:0 15px 0 15px;color:#5f5f5f;" align="left">
        Template Eyes</h1>
      <p style="padding:0 15px 0 15px; line-height:25px;font-size:1.2rem;" color="#5f5f5f;" align="left">
        Not all pre-built email templates are created equal. Some are born with looks so dreamy that you hardly need to change a thing.
        Others, as we will see in today's <strong><em>Feedback Friday</em></strong>, may need some work done on them but can walk a line of being overdone -
        kind of like a movie star who gets too much plastic surgery.
      </p>
      <p style="padding:0 15px 0 15px; line-height:25px;font-size:1.2rem;" color="#5f5f5f;" align="left">This week we jump into a recently submitted B2B email to discuss where you can go wrong in those kinds of scenarios. (For clarity, we are talking about email template scenarios, not plastic surgery scenarios.)
      </p>
      </td>
    </tr>
      <tr>
        <td align="left" style="padding: 0 15px 0 15px;">
          <a class="button" style="padding: 12px 24px 12px 24px;border-radius: 4px; text-align:center;display:inline-block; background-color: #fe4c44;
          text-decoration:none; font-size: .8rem;line-height:24px;color: white;" href="https://www.youtube.com/watch?v=-txf0GL1wK4&feature=youtu.be" target="_blank">
  <strong>BE WISE & CUSTOMIZE</strong></a>
            </td>
      </tr>
    <tr>
      <td>
    <img alt="bottom border of image" width="600px"align="center"
      src="http://i4.createsend1.com/ei/i/53/DC3/DE5/174640/csfinal/rounded-bottom_articles-fancy1-9900000000079e3c.png">
      </img>
    </td>
  </tr>
</table>

<table class="advertise" align="center" width="600px" bgcolor="#f7f7f7">
  <tr>
    <td style="padding:20px 0 20px 0; font-size:.7rem;" align="center">This email is supported by:</td>
  </tr>
  <tr>
    <td style="padding-bottom:35px;" align="center">
      <a href="https://iterable.com/demo-rge/?utm_medium=sponsoredemail&utm_source=really-good-emails&utm_campaign=demo"><img width="560"
        style="max-width:100%; max-height:100%;"
      src="http://i5.createsend1.com/ei/i/53/DC3/DE5/174640/csfinal/ReallyGoodEmail_Banner_Animation_BlueBG_V1_L1R5-9900000000079e3c.gif"></a>
    </td>
  </tr>
</table>

<table class="friday" style="padding-bottom:0px;" align="center" width="600px" bgcolor="white">
  <tr>
    <td align="center" color="#5f5f5f;">
      <h1 style="font-family: Roboto,Tahoma,sans-serif; font-size:1.5rem; line-height:30px;padding:0 15px 0 15px;color:#5f5f5f;" align="left">
        Inspiring Stuff</h1>
      <p style="padding:0 15px 0 15px; line-height:25px;font-size:1.2rem;" color="#5f5f5f;" align="left">
Here's what got us up in a state of mind surfing this week:
      </p>
      </td>
    </tr>
    <tr>
      <td>
        <a class="button" align="center" style="margin:10px; padding: 12px 24px 12px 24px;border-radius: 3px;border: 1px solid red;
        text-align:center;background-color: white;
      text-decoration:none; font-size: .8rem;line-height:24px;color: black;" href="https://www.youtube.com/watch?v=-txf0GL1wK4&feature=youtu.be"
      target="_blank">
      <strong>? SHOULD BUTTONS BE ROUNDED OR SQUARE?</strong></a>
    </td>
  </tr>
  <tr>
    <td>
      <a class="button" align="center" style="margin:10px; padding: 12px 24px 12px 24px;border-radius: 3px;border: 1px solid red;
      text-align:center;background-color: white;
    text-decoration:none; font-size: .8rem;line-height:24px;color: black;" href="https://www.youtube.com/watch?v=-txf0GL1wK4&feature=youtu.be"
    target="_blank">
    <strong>⬛  WHAT'S THIS GONNA LOOK LIKE IN DARK MODE?</strong></a>
  </td>
</tr>
<tr>
  <td>
    <a class="button" align="center" style="margin:10px; padding: 12px 24px 12px 24px;border-radius: 3px;border: 1px solid red;
    text-align:center;background-color: white;
  text-decoration:none; font-size: .8rem;line-height:24px;color: black;" href="https://www.youtube.com/watch?v=-txf0GL1wK4&feature=youtu.be"
  target="_blank">
  <strong>? THE DESIGN SPRINT CHALLENGE OF NICK BRITO</strong></a>
</td>
</tr>
<tr>
  <td>
    <a class="button" align="center" style="margin:10px; padding: 12px 24px 12px 24px;border-radius: 3px;border: 1px solid red;
    text-align:center;background-color: white;
  text-decoration:none; font-size: .8rem;line-height:24px;color: black;" href="https://www.youtube.com/watch?v=-txf0GL1wK4&feature=youtu.be"
  target="_blank">
  <strong>? PRESENTING CONFLICTING OPTIONS IN EMAIL</strong></a>
</td>
</tr>
<tr>
  <td>
    <a class="button" align="center" style="margin:10px; padding: 12px 24px 12px 24px;border-radius: 3px;border: 1px solid red;
    text-align:center;background-color: white;
  text-decoration:none; font-size: .8rem;line-height:24px;color: black;" href="https://www.youtube.com/watch?v=-txf0GL1wK4&feature=youtu.be"
  target="_blank">
  <strong>? COLORFUL GRADIENT CARDS</strong></a>
</td>
</tr>
<tr>
  <td>
<img alt="bottom border of image" width="600px"align="center"
  src="http://i4.createsend1.com/ei/i/53/DC3/DE5/174640/csfinal/rounded-bottom_articles-fancy1-9900000000079e3c.png">
  </img>
</td>
</tr>
</table>

<table class="friday" align="center" width="600px" bgcolor="#f7f7f7">
  <tr>
    <td>
    <h2 style="padding:0 15px 0 15px; line-height:25px;font-size:1.2rem;" color="#5f5f5f;" align="center">Follow Us off the Cliff</h2>
    <p style="padding:0 15px 0 15px; line-height:25px;font-size:1rem;" color="#5f5f5f;" align="center">
      We know what your mother said. If Really Good Emails jumped off a cliff would you go with them? Yes, of course you would. Don’t be silly.</p>
  </td>
  </tr>
</table>

<table class="social" align="center" width="600px" bgcolor="#f7f7f7">
    <tr>
    <td align="center" bgcolor="#38A1F3" style="border-radius:4px;">
    <a href="#" target="_blank" style="font-size: .8rem; color: white;
    text-decoration: none; text-decoration: none;display:inline;padding:10px 30px 10px 30px;"><strong>TWITTER</strong></a>
        </td>
    <tr>
      <td> &nbsp; </td>
    </tr>
    <td align="center" bgcolor="#C92228" style="border-radius:4px;padding:10px;">
      <a href="#" target="_blank" style="font-size: .8rem; color: white;
    text-decoration: none; text-decoration: none;display:inline;"><strong>PINTEREST</strong></a>
        </td>
        <tr>
          <td> &nbsp; </td>
        </tr>
    <td align="center" bgcolor="black" style="border-radius:4px;padding:10px;">
      <a href="#" target="_blank" style="font-size: .8rem; color: white;
    text-decoration: none; text-decoration: none;display:inline;"><strong>CODEPEN</strong></a>
        </td>
         </tr>
</table>

<table style="padding: 25px 0 25px 0" align="center" width="100%" bgcolor="white">
  <tr>
    <td align="center">
      <h3>Design Better.  Spam Never.</h3>
      <p>Update Subscription&nbsp;-&nbsp;Articles & Interviews&nbsp;-&nbsp;Free Resources&nbsp;-&nbsp;View Online</p>
        </td>
</table>

<table class="friday footer" align="center" width="600px" bgcolor="#f7f7f7">
  <tr>
    <td style="color:#9a9ca0; padding: 25px; font-size:.7rem!important; line-height:20px;">
      <p style="font-size:.7rem;">We sent this email to you because of your insatiable thirst for email inspiration that does not make your eyes burn
      like you were thrown into a lake of sliced raw onions—ugh, the worst.</p>

      <p>All this shiznit is © Really Good Emails 2018. All these images belong to us and our moms all said this is
        one instance where we don't have to share if we don't want to. All the emails apparently still belong to the
        individual companies, we just sort of "web photographed" them when they put them in our email inbox. </p>

      <p>If you want to send us gifts, fan mail, or anything that does not include stalking or us waking up with you in our
        living room—you can find us at 1040 W Washington St, Greenville, SC, USA  29601</p>

      <p>Or, if you're just tired of hearing from us, you can unsubscribe too.</p></td>
  </tr>

</table>
  </body>
</html>

1 Ответ

0 голосов
/ 29 ноября 2018

Этот репозиторий GitHub может быть вам полезен: https://github.com/tutsplus/creating-a-future-proof-responsive-email-without-media-queries

По сути, вам нужно сделать «столбцы» из display: inline-block; с фиксированным max-width.Например: если вы установите 2 элемента max-width: 300px; как inline-block с, то на меньших экранах, таких как мобильные;если размер экрана составляет 600 пикселей или меньше, столбцы вместо этого будут накладываться друг на друга.

...