流畅的两列表格布局,不会并排放置表格

时间:2015-02-24 19:04:27

标签: html css email html-table fluid-layout

请原谅我的新手编码,因为它是数百种电子邮件布局的弗兰肯斯坦混合,但是有人可以告诉我为什么我的table布局没有并排显示圆柱表吗?

这两个td元素的类名container-small位于50%width,不会并排放置。我没有使用floatdivs

是不是因为它们应该是同一个td的一部分?请随意提出其他修改/建议,以便我可以改进我的布局。左列必须精确到283px,但右列可以是100%流体。这真的是唯一的要求。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width"/>
        <style type="text/css">
        @media only screen and (min-device-width: 541px), screen and (min-width: 541px) {
            #body {
                width: 600px !important;
            }
        }

        @media only screen and (max-width: 480px) {
            #body {
                width: 100% !important;
            }

            .container {
                display: block !important;
                width: 100% !important;
            }

            .container-small {
                display: block !important;
                width: 100% !important;
            }

            .header-image {
                height: auto !important;
                max-width: 480px !important;
                width: 100% !important;
            }

            .column-image {
                height:auto !important;
                max-width: 283px !important;
                width: 100% !important;
            }

            .content {
                color: #000000;
                font-family: Arial, Helvetica, sans-serif;
                font-size: 100% !important;
                font-weight: normal;
                line-height: 125% !important;
            }
        }

        .container {
            display: block!important;
            max-width: 600px!important;
            margin: 0 auto!important;
            clear: both!important;
        }

        .container-small {
            display: block !important;
            width: 100% !important;
        }

        .header-image {
            height: auto !important;
            max-width: 600px !important;
            width: 100% !important;
        }

        .column-image {
            height: auto !important;
            max-width: 283px !important;
            width: 100% !important;
        }

        .content {
            max-width: 600px;
            margin: 0 auto;
            display: block;
        }

        .content table {
            width: 100%;
        }

        * {
            padding: 0;
            margin: 0;
            font-family: Arial, Helvetica, sans-serif;
            font-size: 100%;
            line-height: 125%;
        }

        img {
            -ms-interpolation-mode: bicubic;
        }

        a {
            color: #EC6129;
            font-family: Arial, Helvetica, sans-serif;
            font-size: 100%;
            font-weight: bold;
            line-height: 125%;
            text-decoration: none;
        }

        .ExternalClass {
            width: 100%;
        }

        .ExternalClass,
        .ExternalClass p,
        .ExternalClass span,
        .ExternalClass font,
        .ExternalClass td,
        .ExternalClass div {
            line-height: 100%;
        }

        .msoFix {
            mso-table-lspace:-1pt;
            mso-table-rspace:-1pt;
        }

        .service-text {
            text-align: center;
        }

        .service-text p {
            text-align: left
        }

        .last {
            margin-bottom: 0px;
        }

        .first {
            margin-top: 0px;
        }

        body, .body {
            -webkit-font-smoothing: antialiased;
            -webkit-text-size-adjust: 100%;
            -ms-text-size-adjust: 100%;
            width: 100% !important;
            height: 100%;
            display: block;
            max-width: 600px;
            margin: 0 auto;
            margin-top: 20px;
            background-color: #999999;
            color: #000000;
            font-family: Arial, Helvetica, sans-serif;
            font-weight: normal;
            font-size: 100%;
            line-height: 125%;
        }

        h1, h2, h3 {
            color: #000000;
            font-family: Arial, Helvetica, sans-serif;
            font-weight: bold;
            font-size: 100%;
            line-height: 125%;
            margin-top: 10px;
            margin-left: 10px;
            margin-right: 10px;
            margin-bottom: 10px;
        }

        h1 {
            font-size: 1.8em;
            margin-top: 10px;
            margin-left: 10px;
            margin-right: 10px;
            margin-bottom: 10px;
        }

        h2 {
            font-size: 1.5em;
            margin-top: 10px;
            margin-left: 10px;
            margin-right: 10px;
            margin-bottom: 10px;
        }

        h3 {
            font-size: 1.2em;
            margin-top: 10px;
            margin-left: 10px;
            margin-right: 10px;
            margin-bottom: 10px;
        }

        p, ul, ol {
            font-size: 1.0em;
            margin-top: 10px;
            margin-left: 10px;
            margin-right: 10px;
            margin-bottom: 10px;
        }

        ul li, ol li {
            list-style-position: inside;
            margin-top: 10px;
            margin-left: 10px;
            margin-right: 10px;
            margin-bottom: 10px;
        }

        sup, sub {
            vertical-align: baseline;
            position: relative;
            top: -0.2em;
        }

        sub {
            top: 0.2em;
        }

        .large-button {
            color: #FFFFFF;
            background-color: #666666;
            border: none;
            border-bottom: 1px solid #666666;
            line-height: 125%;
            display: inline-block;
            width: 100%;
            margin: 0 auto;
            position: relative;
            font-style: normal;
            font-weight: bold;
            font-family: Arial, Helvetica, sans-serif;
            font-size: 100%;
            outline: none;
            text-decoration: none;
            text-align: center;
            cursor: pointer;
            -webkit-border-radius: 2em;
            -moz-border-radius: 2em;
            border-radius: 2em;
        }
        </style>
    </head>
<body align="center" bgcolor="#666666" style="background-color: #666666; width: 100%; max-width: 600px;">

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

    <table id="body" align="center" bgcolor="FFFFFF" border="0" cellpadding="0" cellspacing="0" width="600" style="background-color: #FFFFFF; width: 100%; max-width: 600px; border: 0px solid #999999; border-right: 0px solid #999999;border-left: 0px solid #999999; border-top: 0px solid #999999; border-bottom: 0px solid #999999;">
        <tr>
            <td class="container" align="center" valign="top" width="100%">
                <table border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color: #FFFFFF; width: 100%; max-width: 600px;">
                    <tr>
                        <td class="content" align="center" valign="top" width="100%">
                            <center><img src="https://www.vpcode.com/vfeimages/uploads/email/PureStorage_Email_Banner.png" alt="Pure Storage" style="height: auto !important; width: 100% !important;" class="header-image"/></center>
                        </td>
                    </tr>
                </table>
                <table border="0" cellpadding="0" cellspacing="10" width="600" style="background-color: #FFFFFF; width: 100%; max-width: 600px;">
                    <tr>
                        <td class="container-small" align="center" valign="top" width="50%">
                            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                <tr>
                                    <td class="content" align="left" valign="top">
                                    <img src="https://www.vpcode.com/vfeimages/uploads/email/Vivint_Virtual_Card.png" alt="Vivint Card" align="left" width="283" style="max-width: 283px;" class="column-image" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="content" align="left" valign="top">
                                        <p>Lorem ipsum dolor sit amet.</p>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td class="container-small" align="center" valign="top" width="50%">
                            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                <tr>
                                    <td class="content" align="left" valign="top">
                                        <p>Dear #FirstName#,</p>
                                        <p>Congratulations! $#DollarAmount# in reward money is available to load onto your Visa Prepaid Card! To accept your funding, simply click on the button below. Be sure to have your card handy.</p>
                                        <p><b>Reference Code:</b> #Promocode#</p>
                                        <p>#EmailMessage#</p>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>

                <table border="0" cellpadding="0" cellspacing="10" width="100%" style="background-color: #FFFFFF; width: 100%; max-width: 600px;">
                    <tr>
                        <td align="center" valign="top" width="100%">
                            <table border="0" cellpadding="0" cellspacing="0" style="background-color: #FFFFFF; max-width: 600px; border-collapse: separate; border-radius: 2em;">
                                <tr>
                                    <td class="large-button" align="center" valign="middle" width="100%" style="color: #FFFFFF; font-family: Arial; font-size: 100%; font-weight: bold; line-height: 125%; padding: 10px; text-align: center;">
                                        <center><a href="#vpcodeurl#" title="Click Here" target="_blank" style="color: #FFFFFF; display: block; text-decoration: none; width: 100%;">Click Here to Access Your Reward</a></center>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td class="content" align="left" valign="top" width="100%">
                            <p>If you do not yet have a card, please hold onto this email. You will receive your card shortly and can accept your reward at that time.</p>
                            <p>If you need help, email <a href="mailto:service@prepaidcodecenter.com" title="Email Prepaid Code Center" target="_blank">service@prepaidcodecenter.com</a> or call Cardholder Services at 1-877-325-8444 during standard business hours.</p>    
                        </td>
                    </tr>
                    <tr>
                        <td class="content" align="center" valign="top" width="100%">
                            <center><p>Program issued by The Bancorp Bank, Member FDIC, pursuant to a license from Visa U.S.A. Inc.</p></center>
                        </td>
                    </tr>
                </table>

            </td>
        </tr>
    </table>

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

</body>
</html>

1 个答案:

答案 0 :(得分:0)

问题在于:

    .container-small {
        display: block !important;
        width: 100% !important;
    }

只需删除上面的这两个属性。

以下代码段:

&#13;
&#13;
@media only screen and (min-device-width: 541px), screen and (min-width: 541px) {
            #body {
                width: 600px !important;
            }
        }

        @media only screen and (max-width: 480px) {
            #body {
                width: 100% !important;
            }

            .container {
                display: block !important;
                width: 100% !important;
            }

            .container-small {
                display: block !important;
                width: 100% !important;
            }

            .header-image {
                height: auto !important;
                max-width: 480px !important;
                width: 100% !important;
            }

            .column-image {
                height:auto !important;
                max-width: 283px !important;
                width: 100% !important;
            }

            .content {
                color: #000000;
                font-family: Arial, Helvetica, sans-serif;
                font-size: 100% !important;
                font-weight: normal;
                line-height: 125% !important;
            }
        }

        .container {
            display: block!important;
            max-width: 600px!important;
            margin: 0 auto!important;
            clear: both!important;
        }

       /* REMOVE HERE
        .container-small {
            display: block !important;
            width: 100% !important;
        }
*/

        .header-image {
            height: auto !important;
            max-width: 600px !important;
            width: 100% !important;
        }

        .column-image {
            height: auto !important;
            max-width: 283px !important;
            width: 100% !important;
        }

        .content {
            max-width: 600px;
            margin: 0 auto;
            display: block;
        }

        .content table {
            width: 100%;
        }

        * {
            padding: 0;
            margin: 0;
            font-family: Arial, Helvetica, sans-serif;
            font-size: 100%;
            line-height: 125%;
        }

        img {
            -ms-interpolation-mode: bicubic;
        }

        a {
            color: #EC6129;
            font-family: Arial, Helvetica, sans-serif;
            font-size: 100%;
            font-weight: bold;
            line-height: 125%;
            text-decoration: none;
        }

        .ExternalClass {
            width: 100%;
        }

        .ExternalClass,
        .ExternalClass p,
        .ExternalClass span,
        .ExternalClass font,
        .ExternalClass td,
        .ExternalClass div {
            line-height: 100%;
        }

        .msoFix {
            mso-table-lspace:-1pt;
            mso-table-rspace:-1pt;
        }

        .service-text {
            text-align: center;
        }

        .service-text p {
            text-align: left
        }

        .last {
            margin-bottom: 0px;
        }

        .first {
            margin-top: 0px;
        }

        body, .body {
            -webkit-font-smoothing: antialiased;
            -webkit-text-size-adjust: 100%;
            -ms-text-size-adjust: 100%;
            width: 100% !important;
            height: 100%;
            display: block;
            max-width: 600px;
            margin: 0 auto;
            margin-top: 20px;
            background-color: #999999;
            color: #000000;
            font-family: Arial, Helvetica, sans-serif;
            font-weight: normal;
            font-size: 100%;
            line-height: 125%;
        }

        h1, h2, h3 {
            color: #000000;
            font-family: Arial, Helvetica, sans-serif;
            font-weight: bold;
            font-size: 100%;
            line-height: 125%;
            margin-top: 10px;
            margin-left: 10px;
            margin-right: 10px;
            margin-bottom: 10px;
        }

        h1 {
            font-size: 1.8em;
            margin-top: 10px;
            margin-left: 10px;
            margin-right: 10px;
            margin-bottom: 10px;
        }

        h2 {
            font-size: 1.5em;
            margin-top: 10px;
            margin-left: 10px;
            margin-right: 10px;
            margin-bottom: 10px;
        }

        h3 {
            font-size: 1.2em;
            margin-top: 10px;
            margin-left: 10px;
            margin-right: 10px;
            margin-bottom: 10px;
        }

        p, ul, ol {
            font-size: 1.0em;
            margin-top: 10px;
            margin-left: 10px;
            margin-right: 10px;
            margin-bottom: 10px;
        }

        ul li, ol li {
            list-style-position: inside;
            margin-top: 10px;
            margin-left: 10px;
            margin-right: 10px;
            margin-bottom: 10px;
        }

        sup, sub {
            vertical-align: baseline;
            position: relative;
            top: -0.2em;
        }

        sub {
            top: 0.2em;
        }

        .large-button {
            color: #FFFFFF;
            background-color: #666666;
            border: none;
            border-bottom: 1px solid #666666;
            line-height: 125%;
            display: inline-block;
            width: 100%;
            margin: 0 auto;
            position: relative;
            font-style: normal;
            font-weight: bold;
            font-family: Arial, Helvetica, sans-serif;
            font-size: 100%;
            outline: none;
            text-decoration: none;
            text-align: center;
            cursor: pointer;
            -webkit-border-radius: 2em;
            -moz-border-radius: 2em;
            border-radius: 2em;
        }
&#13;
<body align="center" bgcolor="#666666" style="background-color: #666666; width: 100%; max-width: 600px;">

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

  <table id="body" align="center" bgcolor="FFFFFF" border="0" cellpadding="0" cellspacing="0" width="600" style="background-color: #FFFFFF; width: 100%; max-width: 600px; border: 0px solid #999999; border-right: 0px solid #999999;border-left: 0px solid #999999; border-top: 0px solid #999999; border-bottom: 0px solid #999999;">
    <tr>
      <td class="container" align="center" valign="top" width="100%">
        <table border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color: #FFFFFF; width: 100%; max-width: 600px;">
          <tr>
            <td class="content" align="center" valign="top" width="100%">
              <center>
                <img src="https://www.vpcode.com/vfeimages/uploads/email/PureStorage_Email_Banner.png" alt="Pure Storage" style="height: auto !important; width: 100% !important;" class="header-image" />
              </center>
            </td>
          </tr>
        </table>
        <table border="0" cellpadding="0" cellspacing="10" width="600" style="background-color: #FFFFFF; width: 100%; max-width: 600px;">
          <tr>
            <td class="container-small" align="center" valign="top" width="50%">
              <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                  <td class="content" align="left" valign="top">
                    <img src="https://www.vpcode.com/vfeimages/uploads/email/Vivint_Virtual_Card.png" alt="Vivint Card" align="left" width="283" style="max-width: 283px;" class="column-image" />
                  </td>
                </tr>
                <tr>
                  <td class="content" align="left" valign="top">
                    <p>Lorem ipsum dolor sit amet.</p>
                  </td>
                </tr>
              </table>
            </td>
            <td class="container-small" align="center" valign="top" width="50%">
              <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                  <td class="content" align="left" valign="top">
                    <p>Dear #FirstName#,</p>
                    <p>Congratulations! $#DollarAmount# in reward money is available to load onto your Visa Prepaid Card! To accept your funding, simply click on the button below. Be sure to have your card handy.</p>
                    <p><b>Reference Code:</b> #Promocode#</p>
                    <p>#EmailMessage#</p>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
        </table>

        <table border="0" cellpadding="0" cellspacing="10" width="100%" style="background-color: #FFFFFF; width: 100%; max-width: 600px;">
          <tr>
            <td align="center" valign="top" width="100%">
              <table border="0" cellpadding="0" cellspacing="0" style="background-color: #FFFFFF; max-width: 600px; border-collapse: separate; border-radius: 2em;">
                <tr>
                  <td class="large-button" align="center" valign="middle" width="100%" style="color: #FFFFFF; font-family: Arial; font-size: 100%; font-weight: bold; line-height: 125%; padding: 10px; text-align: center;">
                    <center><a href="#vpcodeurl#" title="Click Here" target="_blank" style="color: #FFFFFF; display: block; text-decoration: none; width: 100%;">Click Here to Access Your Reward</a>
                    </center>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
          <tr>
            <td class="content" align="left" valign="top" width="100%">
              <p>If you do not yet have a card, please hold onto this email. You will receive your card shortly and can accept your reward at that time.</p>
              <p>If you need help, email <a href="mailto:service@prepaidcodecenter.com" title="Email Prepaid Code Center" target="_blank">service@prepaidcodecenter.com</a> or call Cardholder Services at 1-877-325-8444 during standard business hours.</p>
            </td>
          </tr>
          <tr>
            <td class="content" align="center" valign="top" width="100%">
              <center>
                <p>Program issued by The Bancorp Bank, Member FDIC, pursuant to a license from Visa U.S.A. Inc.</p>
              </center>
            </td>
          </tr>
        </table>

      </td>
    </tr>
  </table>

  <!--[if (gte mso 9)|(IE)]>
</td>
</tr>
</table>
<![endif]-->
</body>
&#13;
&#13;
&#13;