微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

html – 在表跨越的表行中添加图像以相对于其他非跨区行保持居中

尝试使用下面的电子邮件签名,但是我无法在跨区行中获取图像以保持所有电子邮件客户端的中心 – 它在JSBin中工作正常,但在GMail中加载时显示不均匀.我需要更改以使其在GMail中正确显示(居中)?

https://jsbin.com/yojinow/1/edit?html,output

<table cellspacing="0" cellpadding="0" border="0" style="width: 390px; height: 70px; table-layout: fixed;">
    <tbody>
        <tr>
            <td rowspan="4" style="width: 70px; height: 70px; padding-right: 0px; overflow: auto;" vertical-align:"middle" valign="middle">
              <a href="http://google.com.au"><img id="Templatelogo" data-class="external" src="https://dummyimage.com/70.png" alt="Company Name" style="display: inline-block; margin-left: auto; margin-right: auto; vertical-align: baseline;" height="100%" width="100%"></a>
            </td>
            <td style="vertical-align: middle; padding-left: 10px; width: 264px; height: 18px;">
              <font style="font-weight: bold; font-family: Arial; font-size: 12pt; color: rgb(81,81,81);">
                John Doe
              </font>
            </td>
        </tr>
        <tr>
          <td style="padding-bottom: 0px; vertical-align: middle; padding-left: 10px; width: 264px; height: 18px;">
            <font style="font-family: Arial; font-size: 10pt; color: rgb(81,81);">
              Accounts
            </font>
          </td>
        </tr>
        <tr>
          <td style="vertical-align: middle; padding-left: 10px; width: 264px; height: 18px;">
            <font style="color: #515151; font-size: 10pt; font-family: Arial">
              T:&nbsp;<a href="tel:+6199999999" style="color: #7cc0cb; text-decoration: none; border-bottom: 0px solid #7cc0cb;">(02) 4399 9999</a>&nbsp;|&nbsp;
              F:&nbsp;<a href="tel:+6199999999" style="color: #7cc0cb; text-decoration: none; border-bottom: 0px solid #7cc0cb;">(02) 4399 9999</a>
            </font>
          </td>
        </tr>
        <tr>
          <td style="vertical-align: middle; padding-left: 10px; width: 264px; height: 18px;">
            <font style="color: #515151; font-size: 10pt; font-family: Arial">
              E:&nbsp;<a href="mailto:example@example.com.au" style="color: #7cc0cb; text-decoration: none; border-bottom: 0px solid #7cc0cb;">example@example.com.au</a>
            </font>
          </td>
        </tr>
    </tbody>
</table>

解决方法

图像必须具有display:block属性才能具有100%的高度
尝试替换display:inline-block;从图像到显示:块;
看看这个例子
#Templatelogo{
  display: block;
  margin-left: auto;
  margin-right: auto;
  vertical-align: baseline;
}

#Templatelogo2{
  display: inline-block;
  margin-left: auto;
  margin-right: auto;
  vertical-align: baseline;
}

tbody{
  display:block;
  border: 1px solid red;
}

h3{
  font-family: Arial;
}
<h3>With display: block;</h3>
<table cellspacing="0" cellpadding="0" border="0" style="width: 390px; height: 70px; table-layout: fixed;">
	<tbody>
		<tr>
            <td rowspan="4" style="width: 70px; height: 70px; padding-right: 0px; overflow: auto;" vertical-align:"middle" valign="middle">
              <a href="http://google.com.au"><img id="Templatelogo" data-class="external" src="https://dummyimage.com/70.png" alt="Company Name" height="100%" width="100%"></a>
            </td>
            <td style="vertical-align: middle; padding-left: 10px; width: 264px; height: 18px;">
              <font style="font-weight: bold; font-family: Arial; font-size: 12pt; color: rgb(81,81);">
                John Doe
              </font>
            </td>
		</tr>
		<tr>
          <td style="padding-bottom: 0px; vertical-align: middle; padding-left: 10px; width: 264px; height: 18px;">
            <font style="font-family: Arial; font-size: 10pt; color: rgb(81,81);">
              Accounts
            </font>
          </td>
		</tr>
		<tr>
          <td style="vertical-align: middle; padding-left: 10px; width: 264px; height: 18px;">
            <font style="color: #515151; font-size: 10pt; font-family: Arial">
              T:&nbsp;<a href="tel:+6199999999" style="color: #7cc0cb; text-decoration: none; border-bottom: 0px solid #7cc0cb;">(02) 4399 9999</a>&nbsp;|&nbsp;
              F:&nbsp;<a href="tel:+6199999999" style="color: #7cc0cb; text-decoration: none; border-bottom: 0px solid #7cc0cb;">(02) 4399 9999</a>
            </font>
          </td>
		</tr>
		<tr>
          <td style="vertical-align: middle; padding-left: 10px; width: 264px; height: 18px;">
            <font style="color: #515151; font-size: 10pt; font-family: Arial">
              E:&nbsp;<a href="mailto:example@example.com.au" style="color: #7cc0cb; text-decoration: none; border-bottom: 0px solid #7cc0cb;">example@example.com.au</a>
            </font>
          </td>
		</tr>
	</tbody>
</table>

<h3>With display: inline-block;</h3>
<table cellspacing="0" cellpadding="0" border="0" style="width: 390px; height: 70px; table-layout: fixed;">
	<tbody>
		<tr>
            <td rowspan="4" style="width: 70px; height: 70px; padding-right: 0px; overflow: auto;" vertical-align:"middle" valign="middle">
              <a href="http://google.com.au"><img id="Templatelogo2" data-class="external" src="https://dummyimage.com/70.png" alt="Company Name" height="100%" width="100%"></a>
            </td>
            <td style="vertical-align: middle; padding-left: 10px; width: 264px; height: 18px;">
              <font style="font-weight: bold; font-family: Arial; font-size: 12pt; color: rgb(81,81);">
              Accounts
            </font>
          </td>
		</tr>
		<tr>
          <td style="vertical-align: middle; padding-left: 10px; width: 264px; height: 18px;">
            <font style="color: #515151; font-size: 10pt; font-family: Arial">
              T:&nbsp;<a href="tel:+6199999999" style="color: #7cc0cb; text-decoration: none; border-bottom: 0px solid #7cc0cb;">(02) 4399 9999</a>&nbsp;|&nbsp;
              F:&nbsp;<a href="tel:+6199999999" style="color: #7cc0cb; text-decoration: none; border-bottom: 0px solid #7cc0cb;">(02) 4399 9999</a>
            </font>
          </td>
		</tr>
		<tr>
          <td style="vertical-align: middle; padding-left: 10px; width: 264px; height: 18px;">
            <font style="color: #515151; font-size: 10pt; font-family: Arial">
              E:&nbsp;<a href="mailto:example@example.com.au" style="color: #7cc0cb; text-decoration: none; border-bottom: 0px solid #7cc0cb;">example@example.com.au</a>
            </font>
          </td>
		</tr>
	</tbody>
</table>

原文地址:https://www.jb51.cc/html/227171.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐