将一个表格置于另一个表格的中心位置

3
我整个星期都在努力解决这个邮件发送器的问题,因为需要尽快发出。我需要将这些产品图片与它们的描述居中对齐,但是我似乎无法在代理机构交接的模板中找到正确的方法。
我已经尝试更改显示属性并添加许多其他属性和方法,例如添加顶部填充(在构建器中视觉上有效,但测试后仍然固定在表格顶部)。这个邮件发送器完全由内联CSS元素的HTML制成,而且有一个用于这些表格的类,但是我找不到这些表格的“全局”CSS属性。
由于我对这方面比较新手,所以如果问题看起来含糊不清,敬请谅解。我附上了问题的截图。
如您所见,产品图片与表格顶部对齐,无论我如何尝试,它们都无法移动到描述的中心位置:

<tr>
  <td align="center" style="padding:0px 0px 50px 0px">
    <table align="center" border="0" cellpadding="0" cellspacing="0" class="m-dw" dir="rtl" width="540">
      <tbody>
        <tr>
          <th align="left" class="m-db m-dw" dir="ltr" valign="top" width="270">
            <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
              <tbody>
                <tr>
                  <td align="center"><img align="middle" alt="" src="https://d15knpe7ll4tpk.cloudfront.net/users/assets/139/images/649_EZVIZ_Camera_Range_Launch/cc599-250.png" style="width: 250px; max-width: 258px; display: block;" width="250"></td>
                </tr>
              </tbody>
            </table>
          </th>
          <th align="left" class="m-db m-dw" dir="ltr" valign="middle" width="270">
            <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
              <tbody>
                <tr>
                  <td align="center" class="p-t20">
                    <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
                      <tbody>
                        <tr>
                          <td style="font-family: Helvetica, Arial, sans-serif; font-size:18px; font-weight:bold; line-height:24px; color:#004b93; text-align:left;"><strong><span style="font-size:14px;"><span style="font-family:arial,helvetica,sans-serif;">CC599<br>
                                                                                                        EZVIZ C3W Huskey Air Wi-Fi Camera 0</span></span><span style="font-size:14px;"><span style="font-family:arial,helvetica,sans-serif;">1</span></span><span style="font-size:14px;"><span style="font-family:arial,helvetica,sans-serif;">80p 2.8mm Fixed Lens</span></span></strong></td>
                        </tr>
                        <tr>
                          <td style="padding:18px 0px 0px 0px; font-family: Helvetica, Arial, sans-serif; font-size:10.16px; font-weight:normal; line-height:16.9px; color:#; text-align:left;"><strong><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:13px;"><span style="color:#616262; font-weight:bold">Features:</span></span></span></strong>
                            <ul>
                              <li><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:13px;"><span style="color:#616262; font-weight:">Wi-Fi Bullet Camera</span></span>
                                </span>
                              </li>
                              <li><span style="font-family:arial,helvetica,sans-serif;"><span style="color:#696969;"><span style="font-size:13px;">1080p Resolution</span></span>
                                </span>
                              </li>
                              <li><span style="font-family:arial,helvetica,sans-serif;"><span style="color:#696969;"><span style="font-size:13px;">Stand-Alone Camera</span></span>
                                </span>
                              </li>
                              <li><span style="font-family:arial,helvetica,sans-serif;"><span style="color:#696969;"><span style="font-size:13px;">Two-way audio up to 5 meters</span></span>
                                </span>
                              </li>
                              <li><span style="font-family:arial,helvetica,sans-serif;"><span style="color:#696969;"><span style="font-size:13px;">30m IR Illumination</span></span>
                                </span>
                              </li>
                              <li><span style="font-family:arial,helvetica,sans-serif;"><span style="color:#696969;"><span style="font-size:13px;">2.8mm Fixed Lens</span></span>
                                </span>
                              </li>
                              <li><span style="font-family:arial,helvetica,sans-serif;"><span style="color:#696969;"><span style="font-size:13px;">IP66</span></span>
                                </span>
                              </li>
                            </ul>
                            <span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:13px; color:#696969;">Hikvision code: CS-CV310-A0-1B2WFR (2.8mm)</span></span>
                          </td>
                        </tr>
                        <!-- Button:: change/replace the button URL twice -->
                        <tr>
                          <td align="left" style="padding:20px 0px 0px 0px">
                            <table align="left" border="0" cellpadding="0" cellspacing="0" width="115">
                              <tbody>
                                <tr>
                                  <td align="center">
                                    <div>
                                      <!--[if mso]>
                                                                                        <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:40px;v-text-anchor:middle;width:150px;" stroke="f" fillcolor="#0a4a93">                                                                                      <w:anchorlock/>                                                                                     <center>                                                                                        <![endif]--><a href="#" style="background-color:#0a4a93;color:#ffffff;display:inline-block;font-family: Helvetica, Arial, sans-serif;font-size:12.8px;font-weight:bold; letter-spacing:0.50px; text-transform:uppercase; line-height:40px;text-align:center;text-decoration:none;width:150px;-webkit-text-size-adjust:none;"
                                        target="_blank">Order now </a>
                                      <!--[if mso]>
                                                                                        </center>                                                                                       </v:rect>                                                                                       <![endif]-->
                                    </div>
                                  </td>
                                </tr>
                              </tbody>
                            </table>
                          </td>
                        </tr>
                        <!-- End Button -->
                      </tbody>
                    </table>
                  </td>
                </tr>
              </tbody>
            </table>
          </th>
        </tr>
      </tbody>
    </table>
  </td>
</tr>

1个回答

5

在包含带有图像的子表格的 th 上使用 style="vertical-align: middle;" 代替 valign="top"

<tr>
  <td align="center" style="padding:0px 0px 50px 0px">
    <table align="center" border="0" cellpadding="0" cellspacing="0" class="m-dw" dir="rtl" width="540">
      <tbody>
        <tr>
          <th align="left" class="m-db m-dw" dir="ltr" style="vertical-align: middle;" width="270">
            <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
              <tbody>
                <tr>
                  <td align="center"><img align="middle" alt="" src="https://d15knpe7ll4tpk.cloudfront.net/users/assets/139/images/649_EZVIZ_Camera_Range_Launch/cc599-250.png" style="width: 250px; max-width: 258px; display: block;" width="250"></td>
                </tr>
              </tbody>
            </table>
          </th>
          <th align="left" class="m-db m-dw" dir="ltr" valign="middle" width="270">
            <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
              <tbody>
                <tr>
                  <td align="center" class="p-t20">
                    <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
                      <tbody>
                        <tr>
                          <td style="font-family: Helvetica, Arial, sans-serif; font-size:18px; font-weight:bold; line-height:24px; color:#004b93; text-align:left;"><strong><span style="font-size:14px;"><span style="font-family:arial,helvetica,sans-serif;">CC599<br>
                                                                                                        EZVIZ C3W Huskey Air Wi-Fi Camera 0</span></span><span style="font-size:14px;"><span style="font-family:arial,helvetica,sans-serif;">1</span></span><span style="font-size:14px;"><span style="font-family:arial,helvetica,sans-serif;">80p 2.8mm Fixed Lens</span></span></strong></td>
                        </tr>
                        <tr>
                          <td style="padding:18px 0px 0px 0px; font-family: Helvetica, Arial, sans-serif; font-size:10.16px; font-weight:normal; line-height:16.9px; color:#; text-align:left;"><strong><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:13px;"><span style="color:#616262; font-weight:bold">Features:</span></span></span></strong>
                            <ul>
                              <li><span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:13px;"><span style="color:#616262; font-weight:">Wi-Fi Bullet Camera</span></span>
                                </span>
                              </li>
                              <li><span style="font-family:arial,helvetica,sans-serif;"><span style="color:#696969;"><span style="font-size:13px;">1080p Resolution</span></span>
                                </span>
                              </li>
                              <li><span style="font-family:arial,helvetica,sans-serif;"><span style="color:#696969;"><span style="font-size:13px;">Stand-Alone Camera</span></span>
                                </span>
                              </li>
                              <li><span style="font-family:arial,helvetica,sans-serif;"><span style="color:#696969;"><span style="font-size:13px;">Two-way audio up to 5 meters</span></span>
                                </span>
                              </li>
                              <li><span style="font-family:arial,helvetica,sans-serif;"><span style="color:#696969;"><span style="font-size:13px;">30m IR Illumination</span></span>
                                </span>
                              </li>
                              <li><span style="font-family:arial,helvetica,sans-serif;"><span style="color:#696969;"><span style="font-size:13px;">2.8mm Fixed Lens</span></span>
                                </span>
                              </li>
                              <li><span style="font-family:arial,helvetica,sans-serif;"><span style="color:#696969;"><span style="font-size:13px;">IP66</span></span>
                                </span>
                              </li>
                            </ul>
                            <span style="font-family:arial,helvetica,sans-serif;"><span style="font-size:13px; color:#696969;">Hikvision code: CS-CV310-A0-1B2WFR (2.8mm)</span></span>
                          </td>
                        </tr>
                        <!-- Button:: change/replace the button URL twice -->
                        <tr>
                          <td align="left" style="padding:20px 0px 0px 0px">
                            <table align="left" border="0" cellpadding="0" cellspacing="0" width="115">
                              <tbody>
                                <tr>
                                  <td align="center">
                                    <div>
                                      <!--[if mso]>
                                                                                        <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:40px;v-text-anchor:middle;width:150px;" stroke="f" fillcolor="#0a4a93">                                                                                      <w:anchorlock/>                                                                                     <center>                                                                                        <![endif]--><a href="#" style="background-color:#0a4a93;color:#ffffff;display:inline-block;font-family: Helvetica, Arial, sans-serif;font-size:12.8px;font-weight:bold; letter-spacing:0.50px; text-transform:uppercase; line-height:40px;text-align:center;text-decoration:none;width:150px;-webkit-text-size-adjust:none;"
                                        target="_blank">Order now </a>
                                      <!--[if mso]>
                                                                                        </center>                                                                                       </v:rect>                                                                                       <![endif]-->
                                    </div>
                                  </td>
                                </tr>
                              </tbody>
                            </table>
                          </td>
                        </tr>
                        <!-- End Button -->
                      </tbody>
                    </table>
                  </td>
                </tr>
              </tbody>
            </table>
          </th>
        </tr>
      </tbody>
    </table>
  </td>
</tr>

注意:包含子表格的单元格在你的代码中是一个th,但从语义上讲,这并不适用 - 它绝对不包含任何类型的标题,而th是为此而设计的。

另外,我不明白为什么你要使用一个只包含一个行和单元格的嵌套表格 - 你可以将图片放入“父”单元格(我提到过的那个th,它应该是一个td),并使其居中显示。


我爱你!谢谢,伙计!我甚至尝试将valign更改为那个,但像个傻瓜一样忘记了样式属性。再次感谢! - Liam Cuffley
@LiamCuffley 如果这是正确的答案,请在点赞按钮周围打上勾。 - Gosi

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接