html - 在跨表行中添加图像以相对于其他非跨行行保持居中
问题描述
尝试使用下面的电子邮件签名,但我无法让跨行中的图像在所有电子邮件客户端中保持居中 - 它在 JSBin 中工作正常,但在 GMail 中加载时显示不均匀。我需要更改什么才能使其在 GMail 中正确显示(居中)?
https://jsbin.com/yojinow/1/edit?html,输出
<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, 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: <a href="tel:+6199999999" style="color: #7cc0cb; text-decoration: none; border-bottom: 0px solid #7cc0cb;">(02) 4399 9999</a> |
F: <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: <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>
解决方案
您指定 4 列,每列 18 像素,但图像所在的列指定 70 像素。它应该是 72 像素(18 像素 x 4 = 72 像素)(列和图像)。如果要在基线上对齐文本,可能需要将文本更改为基线。
<table cellspacing="0" cellpadding="0" border="0" style="width: 390px; height: 70px; table-layout: fixed;">
<tbody>
<tr>
<td rowspan="4" style="width: 72px; height: 72px; 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, 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: <a href="tel:+6199999999" style="color: #7cc0cb; text-decoration: none; border-bottom: 0px solid #7cc0cb;">(02) 4399 9999</a> |
F: <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: <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>
推荐阅读
- python - 需要拆分并检查列表元素是否在 pandas df 中可用
- python - 从视频帧文件路径数据集中获取补丁 ID
- python - Pip 要求获取具有固定专业的最新版本
- pandas - 无法在 jupyter notebbok 中导入我的 csv 文件
- java - LinkedMultiValueMap 与覆盖的方法
- sql - 如何使用 SQL 计算包含特定值的 XML 节点的数量?
- pine-script - 在 TradingView 中更改时间范围时,PineScript Multi TimeFrame 指标会发生变化
- php - 如何在 PHP 中使用 NAV Dynamics WS?
- r - 当 html 节点没有 href/url 时,从嵌入式链接中抓取网页
- amazon-web-services - 什么会更快 - 将文件单独复制到 s3 或将它们移动到存储桶中